Command palette

@yasinsensoy/native

React Native · Components

View

A surface tied to the theme and the appearance system: lays out like a plain View, and optionally takes a card surface (variant), an accent color (tone) and effects (effect).

4 exports

Import

import { View } from "@yasinsensoy/native";

View

component

A surface tied to the theme and the appearance system: lays out like a plain View, and optionally takes a card surface (variant), an accent color (tone) and effects (effect). Same colors, shadows and effect names as the web Card surface; drawn the same on iOS and Android (platform-independent boxShadow and backgroundImage styles, animations on the native driver).

Defaults are given via UIProvider appearance.defaults.view, new variants via appearance.variants.view and new effects via appearance.effects.

Effects listen to raw touch events and do not take the touch: buttons and scrolling inside work as usual; the effect is released when the finger slides more than 10 pixels. Transform effects (scale, bounce, lift, tilt) write on top of style.transform.

View(props: ViewProps): JSX.Element

Examples

<View variant="outline" padding={4} gap={2}>
  <Text variant="h4">Title</Text>
  <Text tone="muted">Content</Text>
</View>

<View variant="glass" effect={["tilt", "glow"]} tone="success" onPress={open} padding={6}>
  <Text>Pro plan</Text>
</View>

<View variant="gradient" effect="beam" active={selected} padding={4} />

Built-in surface variants (same names and colors as Card variant on web; plain and soft exist only on View).

  • plain: no surface is drawn; like a plain View (View's default).
  • outline: a bordered card surface with a light shadow.
  • elevated: a surface with a pronounced shadow and a faint border.
  • filled: borderless, muted background (muted).
  • soft: a light-tinted background and border by color (tone).
  • ghost: no background or border; corners and padding are kept.
  • dashed: dashed border, no background (drop zone, empty state).
  • gradient: a diagonal blend from the accent color into the card.
  • glass: a translucent glass surface with a glowing top edge. React Native has no backdrop blur, so there is no blur; the surface is drawn with the same translucency on both platforms.
type SurfaceVariant = "plain" | "outline" | "elevated" | "filled" | "soft" | "ghost" | "dashed" | "gradient" | "glass"

View corner radius: a name from the theme scale or pixels.

type ViewRadius = "none" | "sm" | "md" | "lg" | "xl" | "full" | number

ViewProps

interface

View props.

Extends: RNViewProps

NameTypeDefaultDescription
ref?Ref<ViewRef>Ref of the underlying native element.
variant?SurfaceVariant | (string & {})"plain"Surface variant: one of the built-in variants (SurfaceVariant) or a name added via UIProvider appearance.variants.view. Defaults to appearance.defaults.view.variant, then "plain".
tone?Tone"primary"Accent color: the color of the effects and the tone of the soft/gradient variants.
effect?EffectPropEffect or effects ("ripple", ["tilt", "glow"]…). See BuiltinEffect. Defaults to appearance.defaults.view.effect; if that is not set either, "scale" when onPress is given, otherwise no effect. "none" disables all of them.
active?booleanfalseKeeps the effects on as if pressed (a selected card, a featured plan): beam rotates, border stays in the accent color, lift stays raised, glow shines in the middle.
radius?ViewRadiusCorner radius: a name from the theme scale (useUI().radius), "full" or pixels. If omitted, the plain variant has no corners and the others use "xl" (like Card on web).
padding?numberPadding in spacing units (space(n); p-4 on web → padding={4}). Follows density. Padding inside style overrides it.
gap?numberGap between children in spacing units (gap-2 → gap={2}). Follows density.
onPress?(event: GestureResponderEvent) => voidWhen given the surface becomes pressable (role button); buttons inside keep receiving their own presses.
onLongPress?(event: GestureResponderEvent) => voidCalled on long press; when given the surface becomes pressable.
disabled?booleanfalseDisables presses and effects and fades the surface.
style?StyleProp<ViewStyle>Container style; added on top of the variant's style.