--- layout: '@/layouts/Doc.astro' title: Button --- import Example from '@/components/Example.astro' import buttonStyle from '@webtui/css/components/button.css?raw' import boxStyle from '@webtui/css/utils/box.css?raw' Displays a button Click Me `} /> ## Import ```css @import '@webtui/css/components/button.css'; ``` To add box borders to button, import the [Box Utility](/webtui/start/ascii-boxes) stylesheet (optional) ```css @import '@webtui/css/utils/box.css'; ``` ## Usage ```html ``` Apply `is-="button"` to any HTML element to style it as a button ```html
div with button style
``` ## Examples ### Variants background0 `} /> Available variants match the [base theme colors](/webtui/start/theming#colors) ### Box Borders Requires the [Box Utility](/webtui/start/ascii-boxes) Round `} /> ### Sizes Default `} /> ### `disabled` Disabled `} /> ## Reference ### Properties - `--button-primary`: The primary color of the button - `--button-secondary`: The secondary color of the button ```css button { --button-primary: black; --button-secondary: green; } ``` Buttons automatically switch between `--button-primary` and `--button-secondary` based on whether `box-` is applied or not button-colors.png ### Extending To extend the Button stylesheet, define a CSS rule on the `components` layer ```css @layer components { button, [is-~='button'] { &[variant-='red'] { --button-primary: red; --button-secondary: white; } /* ... */ } } ``` ### Scope ```css button, [is-~='button'] { /* ... */ } ```