Reference version

This documentation is available as Markdown for AI agents and LLMs. See the full Markdown index or append .md to any documentation URL.

CompositionLocalProvider

A Jetpack Compose CompositionLocalProvider component for providing composition local values to its children.

Android
Included in Expo Go
Recommended version:
~58.0.21

Expo UI CompositionLocalProvider matches the official Jetpack Compose CompositionLocalProvider API. It provides values to all components inside it. It adds no layout of its own, so children keep modifiers such as weight from the parent Row or Column.

Installation

Terminal
- npx expo install @expo/ui
- yarn expo install @expo/ui
- pnpm expo install @expo/ui
- bun expo install @expo/ui

If you are installing this in an existing React Native app, make sure to install expo in your project.

Usage

Smaller touch targets

Material components such as Button, IconButton, Checkbox, RadioButton, and Switch reserve at least 48dp of space for touch, even when they are drawn smaller. Set minimumInteractiveComponentSize to 0 to remove this minimum. Make sure that the controls are still easy to tap.

import { Checkbox, CompositionLocalProvider, Host, IconButton, Row, Text, } from '@expo/ui/jetpack-compose'; import { size } from '@expo/ui/jetpack-compose/modifiers'; import { useState } from 'react'; export default function SmallTouchTargetsExample() { const [checked, setChecked] = useState(false); return ( <Host matchContents> <CompositionLocalProvider values={{ minimumInteractiveComponentSize: 0 }}> <Row horizontalArrangement={{ spacedBy: 8 }} verticalAlignment="center"> <IconButton modifiers={[size(24, 24)]} onClick={() => console.log('Pressed')}> <Text>+</Text> </IconButton> <Checkbox value={checked} onCheckedChange={setChecked} /> </Row> </CompositionLocalProvider> </Host> ); }

API

import { CompositionLocalProvider } from '@expo/ui/jetpack-compose';

Component

CompositionLocalProvider

Android

Type: React.Element<CompositionLocalProviderProps>

Provides composition local values to its children, like Jetpack Compose's CompositionLocalProvider. It adds no layout of its own, so children keep modifiers such as weight from the parent Row or Column.

CompositionLocalProviderProps

children

Android
Optional • Type: ReactNode

The content that receives the values.

values

Android

The values to provide to the children.

Types

CompositionLocalValues

Android

Composition local values that CompositionLocalProvider can provide.

PropertyTypeDescription
minimumInteractiveComponentSize(optional)number

The minimum size, in dp, that Material components such as Button, IconButton, Checkbox, and Switch reserve for their touch target. Maps to LocalMinimumInteractiveComponentSize. Set it to 0 to let these components be smaller than Material's default of 48dp.