docs/components/ui-components/button.mdx
import { StoryExample, StoryWithControls } from '../../src/components/StorybookWrapper'; import { Button } from '../../../superset-frontend/packages/superset-ui-core/src/components/Button';
The Button component is a fundamental UI element used throughout Superset for user interactions.
The default button with primary styling: <StoryExample component={() => ( <Button buttonStyle="primary" onClick={() => console.log('Clicked!')}> Click Me </Button> )} />
<StoryWithControls component={({ buttonStyle, buttonSize, label, disabled }) => ( <Button buttonStyle={buttonStyle} buttonSize={buttonSize} disabled={disabled} onClick={() => console.log('Clicked!')} > {label} </Button> )} props={{ buttonStyle: 'primary', buttonSize: 'default', label: 'Click Me', disabled: false }} controls={[ { name: 'buttonStyle', label: 'Button Style', type: 'select', options: ['primary', 'secondary', 'tertiary', 'success', 'warning', 'danger', 'default', 'link', 'dashed'] }, { name: 'buttonSize', label: 'Button Size', type: 'select', options: ['default', 'small', 'xsmall'] }, { name: 'label', label: 'Button Text', type: 'text' }, { name: 'disabled', label: 'Disabled', type: 'boolean' } ]} />
| Prop | Type | Default | Description |
|---|---|---|---|
buttonStyle | 'primary' | 'secondary' | 'tertiary' | 'success' | 'warning' | 'danger' | 'default' | 'link' | 'dashed' | 'default' | Button style |
buttonSize | 'default' | 'small' | 'xsmall' | 'default' | Button size |
disabled | boolean | false | Whether the button is disabled |
cta | boolean | false | Whether the button is a call-to-action button |
tooltip | ReactNode | - | Tooltip content |
placement | TooltipProps['placement'] | - | Tooltip placement |
onClick | function | - | Callback when button is clicked |
href | string | - | Turns button into an anchor link |
target | string | - | Target attribute for anchor links |
import Button from 'src/components/Button';
function MyComponent() {
return (
<Button
buttonStyle="primary"
onClick={() => console.log('Button clicked')}
>
Click Me
</Button>
);
}
Superset provides a variety of button styles for different purposes:
Buttons come in three sizes: