ReScript Shadcn
Get started
  • Installation
Components
  • Accordion
  • Alert
  • AlertDialog
  • AspectRatio
  • Attachment
  • Avatar
  • Badge
  • Breadcrumb
  • Bubble
  • Button
  • ButtonGroup
  • Calendar
  • Card
  • Carousel
  • Chart
  • Checkbox
  • Collapsible
  • Combobox
  • Command
  • ContextMenu
  • DataTable
  • DatePicker
  • Dialog
  • Direction
  • Drawer
  • DropdownMenu
  • Empty
  • Field
  • HoverCard
  • Input
  • InputGroup
  • InputOtp
  • Item
  • Kbd
  • Label
  • Marker
  • Menubar
  • Message
  • MessageScroller
  • NativeSelect
  • NavigationMenu
  • Pagination
  • Popover
  • Progress
  • RadioGroup
  • Resizable
  • ScrollArea
  • Select
  • Separator
  • Sheet
  • Sidebar
  • Skeleton
  • Slider
  • Sonner
  • Spinner
  • Switch
  • Table
  • Tabs
  • Textarea
  • Toast
  • Toggle
  • ToggleGroup
  • Tooltip
  • Typography

Button

Displays a button or a component that looks like a button.

Installation#

npx shadcn@latest add @rescript-shadcn/Button

Usage#

<Button variant=Outline> {"Button"->React.string} </Button>

Cursor#

Tailwind v4 switched from cursor: pointer to cursor: default for the button component.

If you want to keep the cursor: pointer behavior, add the following code to your CSS file:

globals.css
@layer base {
  button:not(:disabled),
  [role="button"]:not(:disabled) {
    cursor: pointer;
  }
}

Examples#

Size#

Use the size prop to change the size of the button.

Default#

Outline#

Secondary#

Ghost#

Destructive#

Link#

Icon#

With Icon#

Remember to add the data-icon="inline-start" or data-icon="inline-end" attribute to the icon for the correct spacing.

Rounded#

Use the rounded-full class to make the button rounded.

Spinner#

Render a <Spinner /> component inside the button to show a loading state. Remember to add the data-icon="inline-start" or data-icon="inline-end" attribute to the spinner for the correct spacing.

Button Group#

To create a button group, use the ButtonGroup component. See the Button Group documentation for more details.

Link#

You can use the render prop on <Button /> to make another component look like a button. Here's an example of a link that looks like a button.

Remember to set the nativeButton prop to false if you're returning an element that is not a button.

Login

API Reference#

Button#

The Button component is a wrapper around the button element that adds a variety of styles and functionality.

PropTypeDefault
variantDefault | Outline | Ghost | Destructive | Secondary | LinkDefault
sizeDefault | Xs | Sm | Lg | Icon | IconXs | IconSm | IconLgDefault
@react.component
let make = () =>
  <div className="flex flex-wrap items-center gap-2 md:flex-row">
@react.component
let make = () =>
  <div className="flex flex-col items-start gap-8 sm:flex-row">
@react.component
let make = () => <Button> {"Button"->React.string} </Button>
@react.component
let make = () => <Button variant=Outline> {"Outline"->React.string} </Button>
@react.component
let make = () => <Button variant=Secondary> {"Secondary"->React.string} </Button>
@react.component
let make = () => <Button variant=Ghost> {"Ghost"->React.string} </Button>
@react.component
let make = () =>
  <Button variant=Destructive> {"Destructive"->React.string} </Button>
@react.component
let make = () => <Button variant=Link> {"Link"->React.string} </Button>
module LucideIcons = {
  type props = {className?: string, @as("data-icon") dataIcon?: string}
module TablerIcons = {
  type props = {
    className?: string,
@react.component
let make = () =>
  <div className="flex gap-2">
@react.component
let make = () =>
  <div className="flex gap-2">
@@directive("'use client'")

@react.component
@react.component
let make = () =>
  <Button variant=Secondary size=Sm nativeButton=false render={<a href="#" />}>