Paper

A surface container with shadow, padding, and border radius.

import { ... } from '@corndev/ui'

No shadow

Small shadow (default)

Medium shadow

Large shadow

Border, no shadow

HTML

No JavaScript required — these classes are the whole component.

<div class="corn-paper" data-padding="md" data-shadow="sm" data-radius="md">Card</div>

Classes

Class
.corn-paper

Attributes

AttributeValues
data-surfacebase|raised
data-shadownone|sm|md|lg
data-paddingnone|xs|sm|md|lg|xl
data-radiusnone|sm|md|lg
data-borderpresent or absent

Vanilla JS

Optional. createPaper only adds and removes the classes and attributes above, so the HTML is equivalent. Reach for it when you need to change options at runtime.

import { createPaper } from '@corndev/ui';
import '@corndev/ui/theme';

const el = document.querySelector('#target');
const instance = createPaper(el, { /* options */ });

Options

OptionTypeDefaultDescription
shadow'none'|'sm'|'md'|'lg''sm'Elevation.
padding'none'|'xs'|'sm'|'md'|'lg'|'xl''md'
radius'sm'|'md'|'lg''md'
borderbooleanfalseDraw a 1px border in addition to the shadow.
surface'base'|'raised''base'raised sits one step up from the page, so a card reads as a card even where a shadow does not — in a dark theme especially. base is the page’s own background.

React

Paper — from @corndev/ui-react.

Props

PropTypeDefaultDescription
shadow'none'|'sm'|'md'|'lg''sm'Elevation.
padding'none'|'xs'|'sm'|'md'|'lg'|'xl''md'
radius'sm'|'md'|'lg''md'
borderbooleanfalseDraw a 1px border in addition to the shadow.
surface'base'|'raised''base'raised sits one step up from the page, so a card reads as a card even where a shadow does not — in a dark theme especially. base is the page’s own background.
asstring|React.ComponentType'div'Element or component to render as.
classNamestringundefinedMerged with the Corn UI classes.
childrenReact.ReactNodeundefined

Default

Content inside a Paper surface.

<Paper>Content inside a Paper surface.</Paper>

Shadows

No shadow

Small shadow (default)

Medium shadow

Large shadow

<Paper shadow="none">...</Paper>
<Paper shadow="sm">...</Paper>
<Paper shadow="md">...</Paper>
<Paper shadow="lg">...</Paper>

Padding

Extra small padding

Small padding

Medium padding (default)

Large padding

<Paper padding="xs">...</Paper>
<Paper padding="sm">...</Paper>
<Paper padding="md">...</Paper>
<Paper padding="lg">...</Paper>

With border

Paper with a border and no shadow.

<Paper border shadow="none">...</Paper>

Raised

A Paper on the page’s own background shows only its edge, and in a dark theme, where shadows barely read, often not even that. surface="raised" puts it one step up, on --corn-bg-secondary, so a card reads as a card:

<Paper surface="raised" border padding="lg">…</Paper>