HextaUI

Button: Smooth width

The button eases to the width of each label instead of reserving space for the longest one, so nothing around it jumps.

"use client"

import { Button } from "@/components/ui/button"

function wait(ms: number) {
  return new Promise<void>((resolve) => setTimeout(resolve, ms))
}

export function ButtonSmoothWidth() {
  return (
    <Button
      feedback
      loadingLabel="Publishing to 3 regions…"
      successLabel="Live"
      onClick={() => wait(1600)}
    >
      Publish
    </Button>
  )
}

This adds the example as components/examples/button/smooth-width.tsx, together with the Button component and the HextaUI theme tokens it needs.

pnpm dlx shadcn@latest add https://hextaui.com/r/button-smooth-width.json

To add only the component, follow the Button installation.

Props in this example

The Button props this example sets, from the API reference.

PropTypeDefault
feedbackTrack the promise returned from onClick and show its status.
booleanfalse
onClickReturn a promise to drive feedback.
(event) => unknown–
loadingLabelShown next to the spinner. Hidden on icon sizes.
ReactNode–
successLabel
ReactNode"Done"

Every prop is in the Button API reference.

See them all, with keyboard support and accessibility notes, on the Button page.