Skip to main content
KPdfViewerToolbar is controlled entirely through five configuration data classes. You compose them together into a KPdfViewerToolbarConfig that you pass to the config parameter of KPdfViewerToolbar, and separately a KPdfViewerToolbarStyle for visual appearance. Every class ships with a defaults() companion factory so you can use .copy(…) to override only the fields you care about without boilerplate.

KPdfViewerToolbarConfig

The top-level configuration object. Holds visibility, string labels, and icon slots for every toolbar chip.
KPdfViewerToolbarVisibility
required
Controls which chips are rendered. All chips are visible by default. See KPdfViewerToolbarVisibility below.
KPdfViewerToolbarStrings
required
Provides the label text (and lambda formatters) for every chip. See KPdfViewerToolbarStrings below.
KPdfViewerToolbarIcons
required
Provides the optional leading icon composable for every chip. See KPdfViewerToolbarIcons below.
Companion: KPdfViewerToolbarConfig.defaults() is a @Composable function that returns an instance populated with KPdfViewerToolbarVisibility(), KPdfViewerToolbarStrings.defaults(), and KPdfViewerToolbarIcons.defaults().

KPdfViewerToolbarVisibility

Controls which chips the toolbar renders. Every field is a Boolean that defaults to true, so all chips are shown unless you explicitly set a field to false.
Boolean
Show the page summary chip that displays the current page number and total page count. Rendered with the Accent chip style. Default: true.
Boolean
Show the zoom-out chip. The chip is automatically disabled when the viewer is already at minZoom. Default: true.
Boolean
Show the read-only zoom percentage chip. Rendered with the Tonal chip style. Default: true.
Boolean
Show the zoom-in chip. The chip is automatically disabled when the viewer is already at maxZoom. Default: true.
Boolean
Show the save chip. Tapping it calls viewerState.requestSave() internally. Default: true.
Boolean
Show the share chip. You supply the onShareClick handler to KPdfViewerToolbar directly; the SDK does not implement sharing. Default: true.
Boolean
Show the thumbnail-strip toggle chip. Its label and icon change based on the current isThumbnailStripVisible value. Default: true.

KPdfViewerToolbarStrings

Provides every text label shown in the toolbar. Lambda fields receive runtime values so you can produce dynamic strings without holding external state.
(currentPage: Int, pageCount: Int) -> String
Formats the page summary chip label. Receives the 1-based current page number and the total page count. Default: "Page $currentPage / $pageCount", or "Page --" when pageCount is 0.
(zoomPercent: Int) -> String
Formats the zoom percentage label. Receives the current zoom level as an integer percentage (e.g. 150 for 1.5×). Default: "$zoomPercent%".
String
Label for the zoom-out chip. Default: "Zoom Out".
String
Label for the zoom-in chip. Default: "Zoom In".
String
Label for the save chip. Default: "Save".
String
Label for the share chip. Default: "Share".
(isVisible: Boolean) -> String
Formats the thumbnail-toggle chip label. Receives true when the strip is currently visible. Default: "Hide Thumbnails" when visible, "Show Thumbnails" when hidden.
Companion: KPdfViewerToolbarStrings.defaults() returns the defaults described above. It is a plain (non-@Composable) factory.

KPdfViewerToolbarIcons

Provides the optional leading icon composable for each chip. Every field is typed as KPdfToolbarIcon?, which is a typealias for @Composable () -> Unit. Set a field to null to remove the leading icon for that chip.
KPdfToolbarIcon?
Leading icon for the page summary chip. Default: a text glyph "Pg".
KPdfToolbarIcon?
Leading icon for the zoom percentage chip. Default: a text glyph "%".
KPdfToolbarIcon?
Leading icon for the zoom-out chip. Default: a text glyph "-".
KPdfToolbarIcon?
Leading icon for the zoom-in chip. Default: a text glyph "+".
KPdfToolbarIcon?
Leading icon for the save chip. Default: a text glyph "S".
KPdfToolbarIcon?
Leading icon for the share chip. Default: a text glyph "Sh".
KPdfToolbarIcon?
Leading icon shown on the thumbnail-toggle chip when the strip is currently visible. Default: a text glyph "T".
KPdfToolbarIcon?
Leading icon shown on the thumbnail-toggle chip when the strip is currently hidden. Default: a text glyph "T".
Companion: KPdfViewerToolbarIcons.defaults() is a @Composable function that returns the default text-glyph icons listed above.

KPdfViewerToolbarStyle

Controls the visual appearance of the toolbar container and every chip. All color values are resolved at composition time from MaterialTheme.colorScheme, so the toolbar automatically adapts to light and dark themes.
Shape
Shape applied to the toolbar row container. Default: RoundedCornerShape(24.dp).
List<Color>
Gradient color stops for the horizontal background brush of the toolbar container. Default: a three-stop gradient derived from surface, surfaceContainerLowest, and surfaceVariant.
Color
Stroke color for the toolbar container border. Default: outlineVariant at 80% opacity.
Dp
Stroke width for the toolbar container border. Default: 1.dp.
Shape
Shape applied to every chip. Default: RoundedCornerShape(18.dp).
Color
Container color for Default-appearance chips (zoom-out, zoom-in, save, share). Default: surface at 92% opacity.
Color
Container color for Tonal-appearance chips (zoom percentage). Default: surfaceVariant at 82% opacity.
Color
Container color for Accent-appearance chips (page summary, active thumbnail toggle). Default: primaryContainer at 92% opacity.
Color
Container color for disabled chips (zoom-out at min zoom, zoom-in at max zoom). Default: surfaceVariant at 55% opacity.
Dp
Stroke width applied to all chip borders. Default: 1.dp.
Dp
Padding applied inside the toolbar container, surrounding the chip row. Default: 14.dp.
Dp
Horizontal spacing between chips. Default: 10.dp.
Dp
Minimum width enforced on every chip via Modifier.widthIn(min = …). Prevents very short labels from producing narrow chips. Default: 88.dp.
Companion: KPdfViewerToolbarStyle.defaults() is a @Composable function that resolves all color values from the current MaterialTheme.colorScheme.

Customization example

Override only the fields you need using .copy(…). The example below hides the share chip, localizes the save and zoom labels, replaces the zoom icons with Icon composables from Material3, and increases the minimum chip width.

Notes

  • KPdfViewerToolbarConfig.defaults() and KPdfViewerToolbarIcons.defaults() and KPdfViewerToolbarStyle.defaults() are @Composable functions. Call them inside a composable scope; do not call them from a ViewModel or outside composition.
  • KPdfViewerToolbarStrings.defaults() is a plain (non-@Composable) factory and can be called anywhere.
  • The toolbar uses Material3 AssistChip internally. Chip colors and shapes are applied via AssistChipDefaults, so they respect Material3 theming and accessibility contrast requirements.
  • The chip row is horizontally scrollable, so all chips remain accessible even on narrow screens without any configuration change.