# Radius

One setting controls how round the corners are across your app. Controls and surfaces each get corners that suit them.

Womp UI rounds corners from one palette and three roles. A component reads a role, never a palette step. Controls (buttons, inputs, chips) climb with the theme and become capsules at `full`. Surfaces and overlays (cards, popovers, dialogs) have their own corners per theme and never go pill.

The factor system is from [Radix Themes](https://www.radix-ui.com/themes).

## Installation

```bash
npm install @kushagradhawan/kookie-ui
```

## Usage

Set `radius` on the Theme component. Every role moves from this one prop.

```tsx
import { Theme } from '@kushagradhawan/kookie-ui';

<Theme radius="medium"><YourApp /></Theme>
```

## Palette

Raw corners, times `--radius-factor`. `--radius-full` is 9999px at `full` and 0px below it.

```css
var(--radius-0)  /* 0px */
var(--radius-1)  /* 6px */
var(--radius-2)  /* 8px */
var(--radius-3)  /* 10px */
var(--radius-4)  /* 12px */
var(--radius-5)  /* 16px */
var(--radius-6)  /* 20px */
var(--radius-7)  /* 24px */
var(--radius-8)  /* 28px */
var(--radius-9)  /* 32px */
var(--radius-10) /* 40px */
var(--radius-full)
```

## Roles

Each role has four steps, one per size.

```css
var(--radius-control-1..4) /* palette 1 to 4; half the control height at full */
var(--radius-row-1..4)     /* a row in a menu; half the row's height at full */
var(--radius-panel-1..4)   /* a menu, Select or Combobox panel: its row's corner plus its padding */
var(--radius-surface-1..4) /* 16, 20, 24, 28px: cards, popovers, tables, panes */
var(--radius-overlay-1..4) /* 20, 24, 28, 32px: dialogs and sheets */
```

The px are what `large` and `full` draw. A menu panel is its row's corner plus its padding, so the rows sit concentric inside it.

## Nesting

A surface inside a surface is concentric. Its corner is the outer corner minus the outer padding, at least 8px and never more than its own corner. Card does this for you. The floor matters because the padding is about as large as the corner, so the plain rule would square every nested Card.

## Per Theme

Controls scale by `--radius-factor`. Surfaces and overlays are set directly for each Theme radius.

| Radius | Control factor | Surfaces 1–4 | Overlays 1–4 |
| --- | --- | --- | --- |
| `none` | 0 | 0 | 0 |
| `small` | 0.75 | 5, 6, 8, 10px | 6, 8, 10, 12px |
| `medium` | 1 | 12, 18, 24, 30px | 18, 24, 30, 36px |
| `large` | 1.5 | 16, 20, 24, 28px | 20, 24, 28, 32px |
| `full` | 2, plus pill | 16, 20, 24, 28px | 20, 24, 28, 32px |

`large` and `full` share one surface band, so turning the dial up never squares a card. Controls keep climbing past it.

## Mark Ceiling

Checkbox caps its corner at 40% of its own box, so at `full` it stays square and never reads as a Radio. Switch and Radio keep their pill and circle at every theme.

## Scale

### None

Sharp corners everywhere. Geometric, technical interfaces.

```tsx
<Theme radius="none"><YourApp /></Theme>
```

### Small

Tight rounding. Controls at 0.75x, surfaces 5 to 10px.

```tsx
<Theme radius="small"><YourApp /></Theme>
```

### Medium

Standard rounding. Controls at 1x, surfaces 12 to 30px.

```tsx
<Theme radius="medium"><YourApp /></Theme>
```

### Large

Prominent controls against steady surfaces. Controls at 1.5x, surfaces 16 to 28px.

```tsx
<Theme radius="large"><YourApp /></Theme>
```

### Full

Pill-shaped controls on rounded surfaces, and the default. Controls at 2x plus pill, surfaces 16 to 28px.

```tsx
<Theme radius="full"><YourApp /></Theme>
```

## Overrides

Components that accept a `radius` prop re-declare the radius for their subtree.

```tsx
<Theme radius="medium">
  <Button radius="full">Pill button</Button>
  <Accordion.Root radius="small">...</Accordion.Root>
</Theme>
```

In custom CSS, read the role that matches what you are drawing:

```css
.my-panel {
  border-radius: var(--radius-surface-2);
}

.my-control {
  border-radius: var(--radius-control-2);
}
```

## Credits

The factor-based palette is from [Radix Themes](https://www.radix-ui.com/themes) by [WorkOS](https://workos.com/).
