# top

> Applies the physical `top` property, for offsets genuinely tied to the viewport's top side.

```ts
import { insTop } from "@sdxc/u/layout";
```

Applies the physical `top` property, for offsets genuinely tied to the
viewport's top side. `u.insBs()` (`inset-block-start`) covers the
writing-direction-aware default.

## Quick reference

Every documented call, beside the CSS it emits.

| Call | CSS |
| --- | --- |
| `u.insTop(4)` | `css({ top: "calc(var(--ui-spacing, 0.25rem) * 4)" })` |

## Examples

### Basic example

Use `insTop(n)` to set the `top` offset of a positioned element from the spacing scale:

```tsx
<div mix={[...]}>
	<div mix={[relative(), is(48), bs(32), ...]}>
		<div mix={[absolute(), insTop(0), ...]}>insTop(0)</div>
	</div>
	<div mix={[relative(), is(48), bs(32), ...]}>
		<div mix={[absolute(), insTop(6), ...]}>insTop(6)</div>
	</div>
</div>
```

### Placing below the parent

Use `insTop("full")` to place an element right below its positioned parent, like a menu under its button:

```tsx
<div mix={[bs(36)]}>
	<div mix={[relative()]}>
		<button type="button" mix={[...]}>
			Options
		</button>
		<div mix={[absolute(), insTop("full"), insLeft(0), mbs(2), is(40), ...]}>Menu</div>
	</div>
</div>
```

## Using a custom value

Every scale argument also takes a raw CSS value, which passes through untouched.

```ts
u.insTop("2.75rem")
```

## Applying on a state

Wrap the call in a state utility to scope it to one selector.

```ts
u.hover(u.insTop(4))
```

## Responsive design

Wrap the call in a container query to scope it to one width.

```ts
u.at("md", u.insTop(4))
```

## Customizing your theme

### Customizing spacing

Every numeric step multiplies `--ui-spacing`, so redefining it rescales every spacing and sizing utility at once:

```css
:root {
	--ui-spacing: 0.25rem;
}
```

Every call that names the step now reads the new value:

```ts
insTop(4)
```

## Signature

```ts
u.insTop(value: SizeValue)
```
