A button component with support for different colors, sizes and states out of the box. You can also customize it to your needs!
Using the button component is easy. Check out the example below:
import { Button } from '@studiocms/ui/components' ;
You can disable the button component via the disabled
attribute:
import { Button } from '@studiocms/ui/components' ;
< Button color = 'primary' disabled >
The button component supports three different sizes out of the box:
Button (sm)
Button (default)
Button (lg)
import { Button } from '@studiocms/ui/components' ;
< Button color = 'primary' size = 'sm' >
< Button color = 'primary' size = 'lg' >
There is five default colorways that can be used right away:
Default
Primary
Success
Warning
Danger
Default
Primary
Success
Warning
Danger
import { Button } from '@studiocms/ui/components' ;
In addition to colors, the button component can be displayed in three different variants:
import { Button } from '@studiocms/ui/components' ;
< Button color = 'primary' variant = "outlined" >
< Button color = 'primary' variant = "flat" >
Thanks to Astro’s Polymorphic
type, you can change the button’s parent component into whatever HTML tag you need it to be!
Here’s an example where the button is an <a>
tag instead of a <button>
:
import { Button } from '@studiocms/ui/components' ;
< Button color = 'primary' target = "_blank" as = 'a' href = "https://studiocms.dev" >
As mentioned earlier, you can apply your custom styles to the button component! Here’s a gradient button to show you how it’s done:
Custom styles in production
Due to Astro bundling CSS in an honestly, weird way, your custom styles will get overwritten in production unless you use !important
or make
them inline-styles!
import { Button } from '@studiocms/ui/components' ;
< Button style = "background-image: linear-gradient(to top right, #a07cee, #4ff8d2); color: black; font-weight: 600;" >
import { Button } from '@studiocms/ui/components' ;
< Button class = "custom-btn" >
background-image : linear-gradient ( to top right , #a07cee , #4ff8d2 ) !important ;
font-weight : 600 !important ;