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.30

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.

SmallTouchTargetsExample.tsx
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> ); }

Autofill highlight

When autofill fills a text field, Compose paints a semi-transparent yellow over it. Set autofillHighlightColor to change that color, or to transparent to remove it.

AutofillHighlightExample.tsx
import { BasicTextField, CompositionLocalProvider, Host, useNativeState, } from '@expo/ui/jetpack-compose'; import { background, fillMaxWidth, padding, semantics, } from '@expo/ui/jetpack-compose/modifiers'; export default function AutofillHighlightExample() { const email = useNativeState(''); return ( <Host matchContents={{ vertical: true }} style={{ width: '100%' }}> <CompositionLocalProvider values={{ autofillHighlightColor: 'transparent' }}> <BasicTextField value={email} singleLine modifiers={[ fillMaxWidth(), background('#f3f4f6'), padding(12, 10, 12, 10), semantics({ contentType: 'username' }), ]} /> </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
autofillHighlightColor(optional)ColorValue

The color that text fields paint over their content after autofill fills them. Maps to LocalAutofillHighlightBrush as a solid color. Set it to transparent to remove the highlight, for example in a field whose own colors already show that it was filled. Defaults to Compose's semi-transparent yellow (#4DFFEB3B).

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.

Reference version