Number Field
A numeric input element with increment and decrement buttons, and a scrub area.
Derived from Palermo's Input and ghost buttons. Stepper size and radius are guesses.
import { NumberField } from "@replicas/ui";
import { useId } from "react";
export default function NumberFieldDemo() {
const id = useId();
return (
<NumberField.Root id={id} defaultValue={5} min={1} max={50}>
<NumberField.ScrubArea>
<label htmlFor={id}>Seats</label>
</NumberField.ScrubArea>
<NumberField.Group>
<NumberField.Decrement />
<NumberField.Input />
<NumberField.Increment />
</NumberField.Group>
</NumberField.Root>
);
}Prompt
Copy Prompt hands your agent everything it needs to build the Number Field in the Palermo style: the measured tokens, the CSS and the structure.
Show Prompt
# Palermo Number Field
A numeric input element with increment and decrement buttons, and a scrub area.
Build a Number Field in this project that looks and behaves like Palermo's. Measured from the running Palermo app (palermo.tryprofound.com). Keep every value exact. Map the tokens onto the project's own theme variables instead of hard-coding them. Use the project's own component library for behaviour, or [Base UI](https://base-ui.com/react/components/number-field) if it has none.
Fidelity: Derived from Palermo's Input and ghost buttons. Stepper size and radius are guesses.
## Tokens
| Token | Light | Dark |
| --- | --- | --- |
| `--color-bg-primary` | `#fff` | `#171615` |
| `--color-bg-secondary` | `#fafafa` | `#1e1d1c` |
| `--color-fill-red` | `#fb2c36` | `#ff6568` |
| `--color-control-bg` | `#fff` | `#252423` |
| `--color-control-hover` | `#f5f5f5` | `#31302e` |
| `--bg-tertiary` | `#f5f5f5` | `#272625` |
| `--text-primary` | `#18181a` | `#ecebe9` |
| `--text-secondary` | `#787878` | `#aaa8a5` |
| `--text-tertiary` | `#969696` | `#898784` |
| `--text-quaternary` | `#b4b4b4` | `#676563` |
| `--ghost-bg-hover` | `#0000000d` | `#d6d5d412` |
| `--shadow-low` | `var(--surface-shadow-low), var(--shadow-border)` | `var(--surface-shadow-low), var(--shadow-border)` |
| `--shadow-low-focus` | `var(--surface-shadow-low), var(--shadow-border), var(--shadow-solid-border), var(--shadow-focus)` | `var(--surface-shadow-low), var(--shadow-border), var(--shadow-solid-border), var(--shadow-focus)` |
| `--focus-ring` | `#006bff` | `#006bff` |
| `--font-size-small` | `0.8125rem` | `0.8125rem` |
| `--line-height-small` | `18px` | `18px` |
| `--font-weight-normal` | `400` | `400` |
| `--font-weight-medium` | `500` | `500` |
| `--radius-control` | `8px` | `8px` |
| `--radius-6` | `6px` | `6px` |
## CSS
Scoped under `[data-style="palermo"]`; dark rules sit under `[data-theme="dark"]`. The `ui-*` classes and data attributes match the structure below.
```css
[data-style="palermo"] {
.ui-number-field {
--number-field-invalid: var(--color-fill-red);
display: inline-flex;
flex-direction: column;
align-items: flex-start;
gap: 8px;
}
.ui-number-field-scrubArea {
color: var(--text-primary);
font-size: var(--font-size-small);
font-weight: var(--font-weight-medium);
line-height: var(--line-height-small);
cursor: ew-resize;
user-select: none;
& label {
cursor: inherit;
}
}
.ui-number-field-group {
box-sizing: border-box;
display: inline-flex;
align-items: center;
height: 28px;
padding: 0 2px;
border: 1.5px solid transparent;
border-radius: var(--radius-control);
background-color: var(--color-bg-primary);
box-shadow: var(--shadow-low);
@media (hover: hover) {
&:hover:not([data-disabled], :focus-within) {
background-color: var(--color-control-hover);
}
}
&:has(.ui-number-field-input:focus-visible) {
box-shadow: var(--shadow-low-focus);
}
&[data-invalid] {
border-color: var(--number-field-invalid);
}
&[data-disabled] {
background-color: var(--bg-tertiary);
box-shadow: none;
}
}
&[data-theme="dark"] .ui-number-field-group {
background-color: var(--color-bg-secondary);
@media (hover: hover) {
&:hover:not([data-disabled], :focus-within) {
background-color: var(--color-control-bg);
}
}
&[data-disabled] {
background-color: var(--bg-tertiary);
}
}
.ui-number-field-input {
box-sizing: border-box;
width: 6ch;
min-width: 0;
height: 100%;
margin: 0;
padding: 0 4px;
border: none;
background: transparent;
color: var(--text-primary);
font-family: inherit;
font-size: var(--font-size-small);
font-weight: var(--font-weight-normal);
line-height: var(--line-height-small);
font-variant-numeric: tabular-nums;
text-align: center;
outline: none;
&::placeholder {
color: var(--text-tertiary);
}
&[data-disabled] {
color: var(--text-quaternary);
}
}
.ui-number-field-stepper {
display: inline-flex;
flex-shrink: 0;
align-items: center;
justify-content: center;
width: 20px;
height: 20px;
margin: 0;
padding: 0;
border: none;
border-radius: var(--radius-6);
background-color: transparent;
color: var(--text-secondary);
cursor: pointer;
user-select: none;
@media (hover: hover) {
&:hover:not([data-disabled]) {
background-color: var(--ghost-bg-hover);
color: var(--text-primary);
}
}
&:focus-visible {
outline: 1px solid var(--focus-ring);
outline-offset: -1px;
}
&[data-disabled] {
color: var(--text-quaternary);
cursor: not-allowed;
}
& svg {
width: 12px;
height: 12px;
}
}
}
```
## Structure
How Replicas assembles it on Base UI.
```tsx
import { NumberField as BaseNumberField } from "@base-ui/react/number-field";
const join = (base: string, extra?: string) => (extra ? `${base} ${extra}` : base);
function Root({ className, ...props }: Omit<BaseNumberField.Root.Props, "className"> & { className?: string }) {
return <BaseNumberField.Root className={join("ui-number-field", className)} {...props} />;
}
function ScrubArea({ className, ...props }: Omit<BaseNumberField.ScrubArea.Props, "className"> & { className?: string }) {
return <BaseNumberField.ScrubArea className={join("ui-number-field-scrubArea", className)} {...props} />;
}
function Group({ className, ...props }: Omit<BaseNumberField.Group.Props, "className"> & { className?: string }) {
return <BaseNumberField.Group className={join("ui-number-field-group", className)} {...props} />;
}
function Input({ className, ...props }: Omit<BaseNumberField.Input.Props, "className"> & { className?: string }) {
return <BaseNumberField.Input className={join("ui-number-field-input", className)} {...props} />;
}
function Decrement({
className,
children,
...props
}: Omit<BaseNumberField.Decrement.Props, "className"> & { className?: string }) {
return (
<BaseNumberField.Decrement className={join("ui-number-field-stepper", className)} {...props}>
{children ?? (
<svg viewBox="0 0 12 12" fill="none" stroke="currentColor" strokeWidth="1.25" strokeLinecap="round">
<path d="M2.5 6h7" />
</svg>
)}
</BaseNumberField.Decrement>
);
}
function Increment({
className,
children,
...props
}: Omit<BaseNumberField.Increment.Props, "className"> & { className?: string }) {
return (
<BaseNumberField.Increment className={join("ui-number-field-stepper", className)} {...props}>
{children ?? (
<svg viewBox="0 0 12 12" fill="none" stroke="currentColor" strokeWidth="1.25" strokeLinecap="round">
<path d="M2.5 6h7M6 2.5v7" />
</svg>
)}
</BaseNumberField.Increment>
);
}
export const NumberField = {
Root,
ScrubArea,
Group,
Input,
Decrement,
Increment,
};
```
## Example
```tsx
import { NumberField } from "@replicas/ui";
import { useId } from "react";
export default function NumberFieldDemo() {
const id = useId();
return (
<NumberField.Root id={id} defaultValue={5} min={1} max={50}>
<NumberField.ScrubArea>
<label htmlFor={id}>Seats</label>
</NumberField.ScrubArea>
<NumberField.Group>
<NumberField.Decrement />
<NumberField.Input />
<NumberField.Increment />
</NumberField.Group>
</NumberField.Root>
);
}
```
## Foundations
The rest of the Palermo style, as a skill: https://replicas.raphaelsalaja.com/skills/palermo/SKILL.md