All style and behaviour properties are passed as keyword arguments to element functions.
All components accept these layout properties:
width— fixed width in dp (Android) / pt (iOS)height— fixed heightflex— flex grow factor within Column/Rowmargin— outer spacing (int, float, or dict withhorizontal,vertical,left,top,right,bottom)min_width,max_width— width constraintsmin_height,max_height— height constraintsalign_self— override parent alignment ("fill","center", etc.)key— stable identity for reconciliation
pn.Text(text, font_size=None, color=None, bold=False, text_align=None,
background_color=None, max_lines=None)text— display stringfont_size— size in sp (Android) / pt (iOS)color— text colour (#RRGGBBor#AARRGGBB)bold— bold weighttext_align—"left","center", or"right"background_color— view backgroundmax_lines— limit visible lines
pn.Button(title, on_click=None, color=None, background_color=None,
font_size=None, enabled=True)title— button labelon_click— callback() -> Nonecolor— title text colourbackground_color— button backgroundenabled— interactive state
pn.Column(*children, spacing=0, padding=None, alignment=None, background_color=None)
pn.Row(*children, spacing=0, padding=None, alignment=None, background_color=None)spacing— gap between children (dp / pt)padding— inner padding (int for all sides, or dict withhorizontal,vertical,left,top,right,bottom)alignment— cross-axis:"fill","center","leading","trailing","start","end","top","bottom"background_color— container background
pn.View(*children, background_color=None, padding=None)Generic container (UIView / FrameLayout). Supports all layout properties.
pn.SafeAreaView(*children, background_color=None, padding=None)Container that respects safe area insets (notch, status bar).
pn.ScrollView(child, background_color=None)pn.TextInput(value="", placeholder="", on_change=None, secure=False,
font_size=None, color=None, background_color=None)on_change— callback(str) -> Nonereceiving new text
pn.Image(source="", width=None, height=None, scale_type=None, background_color=None)source— image URL (http://.../https://...) or local resource namescale_type—"cover","contain","stretch","center"
pn.Switch(value=False, on_change=None)on_change— callback(bool) -> None
pn.Slider(value=0.0, min_value=0.0, max_value=1.0, on_change=None)on_change— callback(float) -> None
pn.ProgressBar(value=0.0, background_color=None)value— 0.0 to 1.0
pn.ActivityIndicator(animating=True)pn.WebView(url="")pn.Spacer(size=None, flex=None)size— fixed dimension in dp / ptflex— flex grow factor
pn.Pressable(child, on_press=None, on_long_press=None)Wraps any child element with tap/long-press handling.
pn.Modal(*children, visible=False, on_dismiss=None, title=None, background_color=None)Overlay dialog shown when visible=True.
pn.FlatList(data=None, render_item=None, key_extractor=None,
separator_height=0, background_color=None)data— list of itemsrender_item—(item, index) -> Elementfunctionkey_extractor—(item, index) -> strfor stable keysseparator_height— spacing between items