Knit UI
GitHub

Playground

Loading playground…

Playground
<Camera />

Examples

Declarative

Set the starting viewport once, declaratively, via initialViewState.

Loading example…

DeclarativeSourceStorybook

Center And Zoom

Drive center + zoom directly as controlled props.

Loading example…

Center And ZoomSourceStorybook

Bearing And Pitch

A tilted, rotated 3D-style view via bearing + pitch.

Loading example…

Bearing And PitchSourceStorybook

Padding

padding insets the focal point so the center sits off to one side — handy when a sidebar or panel overlaps part of the map.

Loading example…

PaddingSourceStorybook

Fit Bounds On Mount

Fit a bounding box on mount by passing bounds to initialViewState.

Loading example…

Fit Bounds On MountSourceStorybook

Constraints

Constrain interaction with minZoom / maxZoom / maxBounds.

Loading example…

ConstraintsSourceStorybook

Imperative Controls

Imperative control via a CameraRef. The on-screen buttons call flyTo, easeTo, jumpTo, fitBounds, and zoomTo to move the camera between cities.

Loading example…

Imperative ControlsSourceStorybook

Props

PropTypeDefaultDescription
bearingnumber | undefined
durationnumber | undefined
easing"linear" | "ease" | "fly" | undefined
initialViewStateInitialViewState | undefined
maxBoundsLngLatBounds | undefined
maxZoomnumber | undefined
minZoomnumber | undefined
onTrackUserLocationChange((event: TrackUserLocationChangeEvent) => void) | undefined
paddingViewPadding | undefined
pitchnumber | undefined
testIDstring | undefined
trackUserLocationTrackUserLocation | undefined
zoomnumber | undefined
Accessibility & DOM props (2)
PropType
keyKey | null | undefined
refRef<CameraRef> | undefined