| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [View Raw Code] [Original HTTPS Page] |
All visual and layout properties are passed via the style dict (or list of dicts) to element functions. Behavioural properties (callbacks, data, content) remain as keyword arguments.
Layout properties are interpreted by Yoga beside the native widgets, with platform measurements for text and controls. Visual properties are applied by component managers. The browser preview uses Yoga WebAssembly and DOM widgets. See Layout engine for the shared rules and platform differences.
All components accept these layout properties in their style dict:
Most visible components also accept these keyword arguments (see Platform & Accessibility):
pn.View(*children, style={
"flex_direction": "column",
"justify_content": "center",
"align_items": "center",
"overflow": "hidden",
"spacing": 8,
"padding": 16,
"background_color": "#F5F5F5",
})Universal flex container (like React Native's View). Defaults to flex_direction: "column".
Flex container properties (inside style):
Containers also fully support absolute positioning for their children:
pn.View(
pn.View(style={"position": "absolute", "top": 0, "left": 0,
"width": 40, "height": 40, "background_color": "#F00"}),
pn.View(style={"position": "absolute", "bottom": 8, "right": 8,
"width": 40, "height": 40, "background_color": "#0A0"}),
style={"width": 200, "height": 200, "background_color": "#EEE"},
)pn.Text(text, style={"font_size": 18, "color": "#333", "bold": True, "text_align": "center"})Rich text: pass a mix of strings and nested Text elements as the positional parts; they flatten into a single native attributed string (each nested Text styles its own run and inherits the rest):
pn.Text("Total: ", pn.Text("$42", style={"bold": True, "color": "#16A34A"}))pn.Button(title, on_press=handler, style={"color": "#FFF", "background_color": "#007AFF", "font_size": 16})pn.Column(*children, style={"spacing": 12, "padding": 16, "align_items": "center"})
pn.Row(*children, style={"spacing": 8, "justify_content": "space_between"})Convenience wrappers for View with fixed flex_direction:
Column = View with flex_direction: "column" (always vertical)
Row = View with flex_direction: "row" (always horizontal)
*children: child elements (positional)
Style properties:
pn.SafeAreaView(*children, style={"background_color": "#FFF", "padding": 8})Container that respects safe area insets (notch, status bar).
pn.ScrollView(
child,
scroll_axis="vertical", # or "horizontal"
on_scroll=lambda x, y: ..., # content offset as the user scrolls
shows_scroll_indicator=True,
paging_enabled=False, # snap to viewport-sized pages (carousel)
bounces=True, # iOS rubber-band overscroll
keyboard_dismiss_mode=None, # "none" | "on_drag" | "interactive"
content_container_style={"padding": 16},
refresh_control=pn.RefreshControl(refreshing=loading, on_refresh=reload),
style={"background_color": "#FFF"},
)pn.TextInput(value="", placeholder="Enter text", on_change=handler, secure=False,
editable=True, clear_button=True, on_focus=f, on_blur=g,
selection_color="#007AFF", text_content_type="password",
style={"font_size": 16, "color": "#000", "background_color": "#FFF"})pn.Image(source="https://example.com/photo.jpg",
placeholder_color="#E2E8F0",
on_load=lambda: ..., on_error=lambda message: ...,
style={"width": 200, "height": 150, "scale_type": "cover"})Remote sources load through the shared image pipeline: background download, memory + disk caching, request deduplication, and decode downsampled to the view's bounds.
pn.Switch(value=False, on_change=handler)pn.Slider(value=0.5, min_value=0.0, max_value=1.0, on_change=handler)pn.ProgressBar(value=0.5, color="#007AFF", track_color="#EEE", indeterminate=False)pn.ActivityIndicator(animating=True, color="#007AFF", size="large")pn.WebView(
url="https://example.com",
html=None, # render inline HTML instead of a URL
on_load=lambda url: ..., # page finished loading
on_message=lambda msg: ..., # window.pythonnative.postMessage(...)
on_navigation_state_change=lambda url: ...,
inject_javascript="document.body.style.background='#fff'",
scroll_enabled=True,
)pn.Spacer(size=16, flex=1)pn.Pressable(child, on_press=handler, on_long_press=handler)Wraps any child element with tap/long-press handling.
style may also be a callable receiving {"pressed": bool}, re-applied as the press state changes:
pn.Pressable(
child,
on_press=handler,
style=lambda state: {"opacity": 0.6 if state["pressed"] else 1.0},
)pn.Modal(*children, visible=show_modal, on_dismiss=handler, on_show=shown,
title="Confirm", animation_type="slide", transparent=False,
presentation_style="page_sheet", dismiss_on_backdrop=True,
style={"background_color": "#FFF"})Overlay dialog shown when visible=True.
pn.TouchableOpacity(child, on_press=handler, on_long_press=handler,
active_opacity=0.2, disabled=False)Tappable wrapper that dips to active_opacity while pressed (a thin alias over Pressable). disabled=True ignores presses and dims the content.
pn.ImageBackground(child, source="bg.png", scale_type="cover",
style={"width": 320, "height": 180, "padding": 16})Renders child content layered over a background image. Composed from an absolutely-filled Image plus a content View.
pn.Checkbox(value=accepted, on_change=set_accepted, label="Accept terms",
disabled=False, color="#007AFF")| Platform | Native view |
|---|---|
| Android | android.widget.CheckBox |
| iOS | checkmark UIButton |
pn.SegmentedControl(segments=["Day", "Week", "Month"], selected_index=0,
on_change=handler, tint_color="#007AFF")| Platform | Native view |
|---|---|
| Android | toggle row (LinearLayout of buttons) |
| iOS | UISegmentedControl |
pn.DatePicker(value="2026-05-31", mode="date", on_change=handler,
minimum="2026-01-01", maximum="2026-12-31")ISO-8601 string values: "YYYY-MM-DD" (date), "HH:MM" (time), "YYYY-MM-DDTHH:MM" (datetime).
| Platform | Native view |
|---|---|
| Android | DatePickerDialog / TimePickerDialog |
| iOS | UIDatePicker |
pn.Picker(value=selected, items=[{"value": "a", "label": "Apple"}],
on_change=handler, placeholder="Select…")Native dropdown / select. items is a list of {"value": Any, "label": str}.
pn.ScrollView(child, refresh_control=pn.RefreshControl(
refreshing=loading, on_refresh=reload, tint_color="#007AFF"))Pull-to-refresh control, an element of type "RefreshControl", passed as the refresh_control= prop of a ScrollView, FlatList, or SectionList. The scroll container attaches it to its native scroll view rather than rendering it as a child, and raises TypeError for anything that isn't a RefreshControl.
pn.Element("TabBar", {
"items": [
{"name": "Home", "title": "Home"},
{"name": "Settings", "title": "Settings"},
],
"active_tab": "Home",
"on_tab_select": handler,
})Native tab bar, typically created automatically by Tab.Navigator.
| Platform | Native view |
|---|---|
| Android | BottomNavigationView |
| iOS | UITabBar |
pn.FlatList(data=items, render_item=render_fn, key_extractor=key_fn,
item_height=44, separator_height=1,
horizontal=False, num_columns=1,
list_header=pn.Text("Header"), list_footer=pn.Text("Footer"),
list_empty=pn.Text("Nothing here"),
on_end_reached=load_more, on_end_reached_threshold=0.5,
refresh_control=pn.RefreshControl(refreshing=loading, on_refresh=reload),
content_container_style={"padding": 8},
style={"background_color": "#FFF"})| Back | FazBrowse Home | New Git URL |