Build your first app
This guide will walk you through creating a simple application using Apsara components. You’ll learn how to use layouts, buttons, and theme customization.Make sure you’ve installed Apsara before starting this guide.
Import the required components
Start by importing the components and styles you’ll need:The
App.tsx
style.css import provides all the base styles for Apsara components.Create a layout with Flex
Use the The
Flex component to create a flexible layout container:App.tsx
Flex component provides props for controlling flexbox layout:direction: row, column, rowReverse, columnReversealign: start, center, end, stretch, baselinejustify: start, center, end, betweengap: 1-9, extra-small, small, medium, large, extra-large
Add buttons with variants
Add buttons with different variants to your layout:Buttons support multiple variants and colors:
App.tsx
- Variants: solid, outline, ghost, text
- Colors: accent, neutral, danger, success
- Sizes: small, normal
Set up theme provider
Wrap your application with The
ThemeProvider to enable theming and dark mode:App.tsx
ThemeProvider accepts several props:defaultTheme: “light”, “dark”, or “system”style: Theme style variantaccentColor: Primary accent colorgrayColor: Gray scale variantenableSystem: Enable system theme detection (default: true)
Complete example
Here’s a complete working example that combines everything:App.tsx
Using the useTheme hook
Access and control the theme programmatically using theuseTheme hook:
useTheme hook returns:
theme: Current theme setting (“light”, “dark”, or “system”)setTheme: Function to change the themeresolvedTheme: Actual theme being used (resolves “system” to “light” or “dark”)systemTheme: The system’s preferred themethemes: Array of available themes
Layout patterns
Here are some common layout patterns using theFlex component:
Next steps
Now that you’ve built your first app with Apsara, explore more features:Components
Explore all 55+ available components
Theming
Learn how to customize colors and styles
Dark mode
Implement dark mode in your app
Accessibility
Learn about accessibility features
All Apsara components are accessible by default and follow ARIA best practices.