DocsComponentsButton
Button
Displays a button, in six variants and four sizes.
1 file
<pb-ui.button>Button</pb-ui.button>Installation
pyblade-ui add button- Copy this file into your projectcomponents/ui/button.html
@props({'variant': 'default', 'size': 'default', 'type': 'button'}) <button type="{{ type }}" data-slot="button" {{ attributes.cn( "inline-flex shrink-0 cursor-pointer items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-all outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:pointer-events-none disabled:opacity-50 aria-invalid:border-destructive [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4", { 'default': 'bg-primary text-primary-foreground shadow-xs hover:bg-primary/90', 'destructive': 'bg-destructive text-white shadow-xs hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:bg-destructive/60', 'outline': 'border bg-background shadow-xs hover:bg-accent hover:text-accent-foreground dark:border-input dark:bg-input/30 dark:hover:bg-input/50', 'secondary': 'bg-secondary text-secondary-foreground shadow-xs hover:bg-secondary/80', 'ghost': 'hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50', 'link': 'text-primary underline-offset-4 hover:underline', }[variant], { 'default': 'h-9 px-4 py-2 has-[>svg]:px-3', 'sm': 'h-8 gap-1.5 rounded-md px-3 has-[>svg]:px-2.5', 'lg': 'h-10 rounded-md px-6 has-[>svg]:px-4', 'icon': 'size-9', }[size], ) }}>{{ slot }}</button> - Update the path to fit your project
The
componentsfolder is the one set inpyblade.toml.
Usage
The tag <pb-ui.button> is available in all your templates.
<pb-ui.button variant="outline" size="sm">Save</pb-ui.button>Examples
Variants
<div class="flex flex-wrap items-center justify-center gap-2">
<pb-ui.button>Default</pb-ui.button>
<pb-ui.button variant="secondary">Secondary</pb-ui.button>
<pb-ui.button variant="outline">Outline</pb-ui.button>
<pb-ui.button variant="ghost">Ghost</pb-ui.button>
<pb-ui.button variant="destructive">Destructive</pb-ui.button>
<pb-ui.button variant="link">Link</pb-ui.button>
</div>Sizes
<div class="flex flex-wrap items-center justify-center gap-2">
<pb-ui.button size="sm" variant="outline">Small</pb-ui.button>
<pb-ui.button variant="outline">Default</pb-ui.button>
<pb-ui.button size="lg" variant="outline">Large</pb-ui.button>
<pb-ui.button size="icon" variant="outline" aria-label="Add">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round"><path d="M12 5v14M5 12h14"/></svg>
</pb-ui.button>
</div>With an icon
<pb-ui.button variant="outline">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/><path d="m7 10 5 5 5-5"/><path d="M12 15V3"/></svg>
Download
</pb-ui.button>Disabled
<pb-ui.button disabled>Sending…</pb-ui.button>Props
| Prop | Default |
|---|---|
| variant | 'default' |
| size | 'default' |
| type | 'button' |
Any other attribute (class, id, x-on:click, hx-post…) is passed to the root element; your Tailwind classes win over the component's.