Skip to content

Customise React components without forking them

The eight levels of customisation in Vigour Components, from a simple prop to headless hooks, so you can change anything and still get every update.

Most component libraries give you two choices: accept how a component looks and behaves, or fork it. Forking works for a week. Then the library ships a fix, and you have to merge it into your copy by hand – or, more often, you never do.

Vigour Components is built around a different idea: change anything, without leaving the upgrade path. Instead of one big escape hatch, there are eight small ones. Use the lowest level that does the job.

1. Props

The simplest level. Size, variant, state and labels are ordinary props with sensible defaults.

<Button size="sm" variant="outline">
  Export
</Button>

If a prop covers what you need, stop here.

2. Behaviour options

Behaviour is configurable too, not just looks. A select can stay open after a choice, a table can remember column widths, a date picker can start the week on Monday.

<Select options={tags} isMulti behavior={{ closeOnSelect: false }} />

3. Global defaults

If every select in your app should be searchable, set it once in the provider instead of on every screen.

<VigourProvider defaults={{ Select: { isSearchable: true }, Table: { density: "compact" } }}>{children}</VigourProvider>

Theme tokens work the same way: colours, radius, spacing and typography are CSS variables, so a brand change is a token change.

4. Event hooks

Sometimes you need to step in before something happens. Event hooks can inspect a change and cancel it.

<Select options={statuses} onBeforeChange={(next) => (next === "closed" ? confirm("Close this job?") : true)} />

5. Render props

When the default markup is almost right, replace just one piece of it – an option row, an empty state, a cell.

<Select
  options={people}
  renderOption={(person) => (
    <span>
      <Avatar src={person.photo} /> {person.name} · {person.team}
    </span>
  )}
  renderEmpty={() => "No one matches – try a team name"}
/>

6. Slot components

Every component is made of named parts. You can style each part with a class name, or swap a part for your own component while the rest keeps working.

<Table data={orders} classNames={{ headerCell: "uppercase tracking-wide" }} slots={{ Pagination: MyPagination }} />

7. Headless hooks

When you need completely different markup, use the hook behind the component. You get the state, keyboard handling and accessibility attributes; you write the HTML.

const select = useSelect({ options, value, onChange });

return (
  <div {...select.rootProps}>
    <button {...select.triggerProps}>{select.selectedLabel ?? "Choose"}</button>
    {select.isOpen && (
      <ul {...select.listProps}>
        {select.options.map((o) => (
          <li key={o.value} {...select.getOptionProps(o)}>
            {o.label}
          </li>
        ))}
      </ul>
    )}
  </div>
);

This is how you build something that looks nothing like our select, and still get our keyboard and screen-reader behaviour for free.

8. Eject (Core edition)

The last resort, for when you truly need to own a component. The command copies that component's source into your project, and from then on it is yours.

npx vigour add select

Ejecting is per component. Everything else keeps updating with the package.

Choosing the right level

A simple rule of thumb:

You want to…Use
Change size, colour or stateProps
Change how it behavesBehaviour options
Make the same change everywhereGlobal defaults
Stop or check a changeEvent hooks
Change what one part showsRender props
Restyle or replace one partSlot components
Build completely different markupHeadless hooks
Own the code for goodEject

Each step down gives you more control and a little more to maintain. Most screens never need to go past level 5.

Why this matters

The whole point of a component library is that improvements reach every app. Forks break that promise. A layered approach keeps it: you get exactly the screen you want, and next month's accessibility fix still arrives with a version bump.

Read why we ship components as packages in Stop copy-pasting UI components into every project, try the live demos, or install the developer preview.