API

Style reference

This page lists every key of the style prop. The keys and their types come from the generated declarations in .nsh/types/nsh/types.d.ts, so your editor checks them as you type. Layout is flexbox with a column default, numbers are points, and the CSS features are there too: grid, gradients, box shadows, filters, blend modes, outlines, transitions and keyframe animations.

For how to apply styles, combine them with classes and inherit text styles, see Styling. For the class syntax, see the Tailwind reference.

#The four interfaces

Each interface extends the one before it:

InterfaceExtendsUsed by
LayoutStyleLayout of every element (flexbox, grid, sizes, spacing, position)
ViewStyleLayoutStyle<View>, <Scroll>, <List>, controls and every other element
TextStyleViewStyle<Text> and <Input> (and views, whose text styles pass to the text inside them)
ImageStyleViewStyle<Image>
import type { ViewStyle, TextStyle } from "nsh";
import { Text, View } from "nsh";

const card: ViewStyle = {
  padding: 16,
  borderRadius: 12,
  backgroundColor: "#fff",
  boxShadow: "0 4px 12px rgb(0 0 0 / 0.08)",
};

const title: TextStyle = { fontSize: 17, fontWeight: "600", color: "#111" };

<View style={card}>
  <Text style={title}>Hello</Text>
</View>;

style also takes an array; entries merge left to right and falsy entries are skipped, so conditional styles need no spreading:

<View style={[card, selected() && { borderColor: "#2563eb", borderWidth: 2 }]} />

#Value types

TypeAccepts
numberPoints (density-independent). 1 is one point on iOS and one dp on Android.
DimensionValuenumber (points), `${number}%` (of the parent), or "auto".
LengthValuenumber (points) or `${number}%`. No "auto".
ColorValueA CSS color string: #rgb, #rgba, #rrggbb, #rrggbbaa, rgb(), rgba(), hsl(), hsla(), oklch(), oklab(), or a named CSS color (black, white, transparent, rebeccapurple, …).
NativeNodeA native animated value or a node derived from it (see nsh/animated). Accepted by backgroundColor, opacity and the steps of transform; the value then animates on the UI thread without JS.

Strings with CSS syntax (boxShadow, backgroundImage, filter, gridTemplateColumns, …) take lengths in px and bare numbers (both points), pt, or rem (16 points).

#LayoutStyle

Layout is computed in Rust (flexbox and CSS grid). The defaults differ from CSS’s: display: "flex", flexDirection: "column", flexShrink: 0, alignContent: "flex-start", alignItems: "stretch", and no automatic minimum size. See Layout.

#Display and position

KeyTypeDescription
display"flex" | "grid" | "block" | "none"The layout of the children. "none" removes the element from layout and hides it. "block" stacks children as CSS block layout does. Default "flex".
position"relative" | "absolute""absolute" takes the element out of the flow and places it by top / right / bottom / left relative to its parent. Default "relative".
topDimensionValueOffset from the parent’s top edge (absolute) or from the element’s own position (relative).
rightDimensionValueOffset from the right edge. In right-to-left layouts it means the end edge.
bottomDimensionValueOffset from the bottom edge.
leftDimensionValueOffset from the left edge. In right-to-left layouts it means the start edge.
startDimensionValueLeft in left-to-right layouts, right in right-to-left ones.
endDimensionValueRight in left-to-right layouts, left in right-to-left ones.
zIndexnumberOrder among siblings (stable for equal values); also the native stacking order.
direction"inherit" | "ltr" | "rtl"Layout direction, inherited by default. Right to left, left and right properties mean start and end.

#Flexbox

KeyTypeDescription
flexDirection"row" | "column" | "row-reverse" | "column-reverse"The main axis. Default "column".
flexWrap"wrap" | "nowrap" | "wrap-reverse"Whether children wrap onto several lines. Default "nowrap".
flexnumberOne number, not the CSS shorthand: a positive number sets flexGrow to it, flexShrink: 1 and flexBasis: 0; 0 makes the element inflexible; a negative number shrinks it down to its minimum size.
flexGrownumberHow much of the free space the element takes. Default 0.
flexShrinknumberHow much the element shrinks when space runs out. Default 0, not 1 as in CSS.
flexBasisDimensionValueThe main-axis size before free space is distributed.
justifyContent"flex-start" | "flex-end" | "center" | "space-between" | "space-around" | "space-evenly" | "stretch"Distribution of children along the main axis. Default "flex-start".
alignItems"flex-start" | "flex-end" | "center" | "stretch" | "baseline"Alignment of children on the cross axis. Default "stretch".
alignSelf"auto" | "flex-start" | "flex-end" | "center" | "stretch" | "baseline"Overrides the parent’s alignItems for this element.
alignContent"flex-start" | "flex-end" | "center" | "stretch" | "space-between" | "space-around" | "space-evenly"Distribution of wrapped lines (and grid tracks) on the cross axis. Default "flex-start".
gapLengthValueSpace between rows and columns of children.
rowGapLengthValueSpace between rows.
columnGapLengthValueSpace between columns.

#Grid

Set display: "grid" to lay out children in a CSS grid. Track lists use CSS syntax.

KeyTypeDescription
gridTemplateColumnsstringColumn tracks: "repeat(3, 1fr)", "200px 1fr", minmax(), auto-fill / auto-fit, line names.
gridTemplateRowsstringRow tracks, same syntax.
gridAutoColumnsstringSize of implicitly created columns.
gridAutoRowsstringSize of implicitly created rows.
gridAutoFlow"row" | "column" | "dense" | "row dense" | "column dense"How items without a placement fill the grid.
gridColumnnumber | stringColumn placement: "1 / 3", "span 2", a line number or a line name.
gridColumnStartnumber | stringStart column line.
gridColumnEndnumber | stringEnd column line.
gridRownumber | stringRow placement, same syntax as gridColumn.
gridRowStartnumber | stringStart row line.
gridRowEndnumber | stringEnd row line.
justifyItems"flex-start" | "flex-end" | "center" | "stretch" | "baseline"How grid items sit in their areas along the row.
justifySelf"auto" | "flex-start" | "flex-end" | "center" | "stretch" | "baseline"Overrides justifyItems for this item.
<View style={{ display: "grid", gridTemplateColumns: "repeat(3, 1fr)", gap: 8 }}>
  <View style={{ gridColumn: "span 2", height: 60, backgroundColor: "#c7d2fe" }} />
  <View style={{ height: 60, backgroundColor: "#a5b4fc" }} />
</View>

#Size

KeyTypeDescription
widthDimensionValueWidth.
heightDimensionValueHeight.
minWidthLengthValueMinimum width.
minHeightLengthValueMinimum height.
maxWidthLengthValueMaximum width.
maxHeightLengthValueMaximum height.
aspectRationumberWidth divided by height; the missing dimension is computed from the other one.

#Margin

Margins accept "auto" (absorbs free space, as in flexbox) and negative values.

KeyTypeDescription
marginDimensionValueAll four sides.
marginHorizontalDimensionValueLeft and right.
marginVerticalDimensionValueTop and bottom.
marginTopDimensionValueTop.
marginRightDimensionValueRight.
marginBottomDimensionValueBottom.
marginLeftDimensionValueLeft.
marginStartDimensionValueLeft in left-to-right layouts, right in right-to-left ones.
marginEndDimensionValueThe opposite of marginStart.

#Padding

KeyTypeDescription
paddingLengthValueAll four sides.
paddingHorizontalLengthValueLeft and right.
paddingVerticalLengthValueTop and bottom.
paddingTopLengthValueTop.
paddingRightLengthValueRight.
paddingBottomLengthValueBottom.
paddingLeftLengthValueLeft.
paddingStartLengthValueLeft in left-to-right layouts, right in right-to-left ones.
paddingEndLengthValueThe opposite of paddingStart.

#ViewStyle

Everything drawn by a view. All keys of LayoutStyle apply too.

#Background

KeyTypeDescription
backgroundColorColorValue | NativeNodeThe fill color. Takes a native animated color.
backgroundImagestringCSS gradients drawn over the background color: linear-gradient(...), radial-gradient(...), conic-gradient(...), several separated by commas.
experimental_backgroundImagestringAlias of backgroundImage.
<View style={{ height: 120, borderRadius: 16, backgroundImage: "linear-gradient(135deg, #6366f1, #ec4899)" }} />

#Borders

KeyTypeDescription
borderWidthnumberWidth of all four sides.
borderTopWidthnumberTop side.
borderRightWidthnumberRight side.
borderBottomWidthnumberBottom side.
borderLeftWidthnumberLeft side.
borderStartWidthnumberStart side (left in left-to-right layouts).
borderEndWidthnumberEnd side.
borderColorColorValueColor of all four sides.
borderTopColorColorValueTop side.
borderRightColorColorValueRight side.
borderBottomColorColorValueBottom side.
borderLeftColorColorValueLeft side.
borderStartColorColorValueStart side.
borderEndColorColorValueEnd side.
borderStyle"solid" | "dashed" | "dotted"Line style. Default "solid".

#Corners

KeyTypeDescription
borderRadiusnumberRadius of all four corners.
borderTopLeftRadiusnumberTop-left corner.
borderTopRightRadiusnumberTop-right corner.
borderBottomRightRadiusnumberBottom-right corner.
borderBottomLeftRadiusnumberBottom-left corner.
borderTopStartRadiusnumberTop corner on the start side.
borderTopEndRadiusnumberTop corner on the end side.
borderBottomStartRadiusnumberBottom corner on the start side.
borderBottomEndRadiusnumberBottom corner on the end side.
borderCurve"circular" | "continuous""continuous": corners whose curvature eases into the edges, like iOS app icons. Where the box is too small the curve falls back to circular, so pills stay pills. Works on both platforms.

#Outline

An outline is drawn outside the border and takes no space in layout.

KeyTypeDescription
outlineWidthnumberLine width.
outlineColorColorValueLine color.
outlineStyle"solid" | "double" | "dashed" | "dotted" | "none" | "hidden"Line style.
outlineOffsetnumberDistance from the border edge; negative values move it inside.

#Shadows

Two ways to cast a shadow: the CSS boxShadow (several layers, spread, inset) or the four shadow* keys.

KeyTypeDescription
boxShadowstringCSS box-shadow: offsets, blur, spread and color, several layers separated by commas, inset for inner shadows.
shadowColorColorValueShadow color.
shadowOffset{ width: number; height: number }Offset. Default { width: 0, height: -3 }.
shadowOpacitynumberOpacity, 0 to 1. Default 0 (no shadow).
shadowRadiusnumberBlur radius. Default 3.
<View style={{ padding: 16, borderRadius: 12, backgroundColor: "#fff",
  boxShadow: "0 1px 2px rgb(0 0 0 / 0.06), 0 8px 24px -4px rgb(0 0 0 / 0.12)" }} />

#Opacity, visibility and overflow

KeyTypeDescription
opacitynumber | NativeNode0 (invisible) to 1. Takes a native animated value.
visibility"visible" | "hidden" | "collapse"Hidden views keep their space in layout (unlike display: "none").
overflow"visible" | "hidden""hidden" clips children to the view’s bounds (and corners).
backfaceVisibility"visible" | "hidden""hidden": invisible while a 3D rotation turns it away.

#Transforms

KeyTypeDescription
transformTransformStep[]A list of steps, applied right to left like CSS.
transformOriginstring | (number | string)[]The point transform acts around: keywords, percentages and lengths ("top left", "50% 0", [10, 20]). Default the center.

A TransformStep is an object with one key:

StepValueNative animated
translateX, translateYnumber (points)yes
scale, scaleX, scaleYnumber (factor)yes
rotate, rotateZ, rotateX, rotateYnumber (degrees) or string ("45deg", "0.5rad")yes
skewX, skewYnumber (degrees) or stringno
perspectivenumberno
<View style={{ transform: [{ perspective: 600 }, { rotateY: "20deg" }, { scale: 0.95 }] }} />

#Filters and blending

KeyTypeDescription
filterstringCSS filters of the view and its content: brightness(), contrast(), grayscale(), hue-rotate(), invert(), saturate(), sepia(), opacity(), blur(), drop-shadow().
backdropFilterstringCSS filters of what is behind the view, such as "blur(10px)" for frosted glass.
mixBlendMode"normal" | "multiply" | "screen" | "overlay" | "darken" | "lighten" | "color-dodge" | "color-burn" | "hard-light" | "soft-light" | "difference" | "exclusion" | "hue" | "saturation" | "color" | "luminosity" | "plus-darker" | "plus-lighter"How the view blends with what is behind it.

#Transitions

When a transitioned property changes (from a new style, a class or a variant such as active:), the platform animates it natively. No JS runs during the animation.

KeyTypeDescription
transitionPropertystringComma-separated properties that animate: "all", "colors" (color, backgroundColor, borderColor, …), "opacity", "transform", "boxShadow", "borderRadius", "borderWidth", or "none".
transitionDurationnumber | "${number}ms" | "${number}s"Milliseconds as a number, or "150ms" / "0.2s".
transitionDelaynumber | "${number}ms" | "${number}s"Delay before the transition starts.
transitionTimingFunction"linear" | "ease" | "ease-in" | "ease-out" | "ease-in-out" | "cubic-bezier(...)"The easing curve.
<View
  onPress={() => open.set(!open())}
  style={{ height: open() ? 160 : 56, opacity: open() ? 1 : 0.8,
    transitionProperty: "opacity, transform", transitionDuration: 200 }}
/>

#Keyframe animations

Built-in keyframe animations, run natively (Tailwind’s animate-*).

KeyTypeDescription
animationName"none" | "spin" | "ping" | "pulse" | "bounce"The animation.
animationDurationnumber | "${number}ms" | "${number}s"Length of one iteration.
animationDelaynumber | "${number}ms" | "${number}s"Delay before the first iteration.
animationTimingFunction"linear" | "ease" | "ease-in" | "ease-out" | "ease-in-out" | "cubic-bezier(...)"The easing curve.
animationIterationCountnumber | "infinite"How many times it runs.

For animations driven by values, gestures or springs, use nsh/animated instead.

#Pointer

KeyTypeDescription
cursor"auto" | "default" | "pointer" | "text" | "grab" | "grabbing" | "not-allowed" | ... (every CSS cursor keyword, and "none")The pointer shape over the view, for pointers (iPad trackpads, Mac Catalyst, desktops).

#TextStyle

Text styles apply to <Text> and <Input>. They are also inherited, as in CSS: text properties set on a view pass to the texts and inputs inside it, and nested <Text> spans inherit from their parent text. All keys of ViewStyle apply too. See Text.

#Font

KeyTypeDescription
colorColorValueText color.
fontSizenumberSize in points.
fontWeight"normal" | "bold" | number | "${number}""normal" (400), "bold" (700) or 100–900.
fontFamilystringA system family, or the name an imported font evaluates to (import Inter from "./Inter.ttf"). See Fonts.
fontStyle"normal" | "italic"Italic.
fontVariant("small-caps" | "oldstyle-nums" | "lining-nums" | "tabular-nums" | "proportional-nums")[]OpenType number and letter forms. tabular-nums keeps digits the same width, useful for counters and timers.

#Spacing and alignment

KeyTypeDescription
lineHeightnumberLine height in points.
letterSpacingnumberExtra space between characters, in points.
textAlign"auto" | "left" | "center" | "right" | "justify"Horizontal alignment.
textAlignVertical"auto" | "top" | "center" | "bottom"Where text shorter than its box sits (a <Text> with a height).
writingDirection"auto" | "ltr" | "rtl"Base direction of the text; "auto" takes it from the content.
textTransform"none" | "uppercase" | "lowercase" | "capitalize"Case transformation.

#Decoration

KeyTypeDescription
textDecorationLine"none" | "underline" | "line-through" | "underline line-through"Lines drawn with the text.
textDecorationColorColorValueColor of the lines (default the text color).
textDecorationStyle"solid" | "double" | "dotted" | "dashed" | "wavy"Line style.
textDecorationThicknessnumber | "auto" | "from-font"Line thickness.
textUnderlineOffsetnumber | "auto"Distance of the underline from the baseline.

#Text shadow

KeyTypeDescription
textShadowColorColorValueShadow color.
textShadowOffset{ width: number; height: number }Shadow offset.
textShadowRadiusnumberBlur radius.

#ImageStyle

All keys of ViewStyle, plus:

KeyTypeDescription
tintColorColorValueRecolors a template image (every opaque pixel takes this color), for monochrome icons.

How an image fills its box is the resizeMode prop of <Image>, not a style; see image.

#Props that look like styles

Some settings are props in nsh, not style keys. Their Tailwind classes exist, but an explicit prop wins over the class:

SettingPropClass
Line limitnumberOfLines on <Text>line-clamp-*, truncate
Ellipsis positionellipsizeMode on <Text>text-ellipsis, text-clip
Touch pass-throughpointerEventspointer-events-none, pointer-events-auto
Image fitresizeMode on <Image>object-cover, object-contain, …
Selectable textselectable on <Text>select-text, select-none
Placeholder colorplaceholderTextColor on <Input>placeholder:text-*
Material shadow (Android)android={{ elevation }}