Skip to main content

What we’ll build

We’ll build a flexible button component with multiple variants and states from scratch.
1

Create your primitive component

Start with a basic, unstyled button component:
button-primitive.tsx
2

Define your styles

Create a style definition using recast.styles():
button.styles.ts
3

Create your styled component

Apply the styles to your primitive:
button.tsx
4

Use your component

Now you can use your button with full TypeScript support:

Advanced: Adding conditional styles

For more complex styling logic, use conditionals:
Advanced Button

Advanced: Style extraction

Extract computed styles for use with other libraries:
You’re ready! You now have a fully functional, type-safe, performant button component. Apply these same patterns to build any component in your design system.