or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

Files

docs

advanced-features.mdcharts-visualization.mdevents-interaction.mdindex.mdlayout-navigation.mdtheming-styling.mdui-controls.mdutilities-platform.md

ui-controls.mddocs/

0

# UI Controls

1

2

This document covers Flet's comprehensive UI control library, including basic display controls, input controls, buttons, dialogs, and selection controls.

3

4

## Import

5

6

```python

7

import flet as ft

8

```

9

10

## Basic Display Controls

11

12

### Text

13

14

```python { .api }

15

class Text(Control):

16

"""Text display control."""

17

18

def __init__(

19

self,

20

value: str = None,

21

size: float = None,

22

color: str = None,

23

bgcolor: str = None,

24

weight: FontWeight = None,

25

italic: bool = None,

26

font_family: str = None,

27

text_align: TextAlign = None,

28

overflow: TextOverflow = None,

29

max_lines: int = None,

30

selectable: bool = None,

31

spans: List[TextSpan] = None,

32

style: TextStyle = None,

33

**kwargs

34

)

35

```

36

37

**Parameters:**

38

- `value` (str, optional): Text content to display

39

- `size` (float, optional): Font size in logical pixels

40

- `color` (str, optional): Text color

41

- `bgcolor` (str, optional): Background color

42

- `weight` (FontWeight, optional): Font weight (NORMAL, BOLD, etc.)

43

- `italic` (bool, optional): Whether text is italicized

44

- `font_family` (str, optional): Font family name

45

- `text_align` (TextAlign, optional): Text alignment (LEFT, CENTER, RIGHT, etc.)

46

- `overflow` (TextOverflow, optional): How to handle text overflow

47

- `max_lines` (int, optional): Maximum number of lines

48

- `selectable` (bool, optional): Whether text can be selected

49

- `spans` (List[TextSpan], optional): Rich text spans

50

- `style` (TextStyle, optional): Advanced text styling

51

52

**Example:**

53

```python

54

ft.Text(

55

"Hello, World!",

56

size=30,

57

color=ft.colors.BLUE,

58

weight=ft.FontWeight.BOLD,

59

text_align=ft.TextAlign.CENTER

60

)

61

```

62

63

### Icon

64

65

```python { .api }

66

class Icon(Control):

67

"""Icon display control."""

68

69

def __init__(

70

self,

71

name: str = None,

72

color: str = None,

73

size: float = None,

74

tooltip: str = None,

75

**kwargs

76

)

77

```

78

79

**Parameters:**

80

- `name` (str, optional): Icon name from Icons or CupertinoIcons

81

- `color` (str, optional): Icon color

82

- `size` (float, optional): Icon size in logical pixels

83

- `tooltip` (str, optional): Tooltip text on hover

84

85

**Example:**

86

```python

87

ft.Icon(

88

ft.icons.FAVORITE,

89

color=ft.colors.PINK,

90

size=30

91

)

92

```

93

94

### Image

95

96

```python { .api }

97

class Image(Control):

98

"""Image display control."""

99

100

def __init__(

101

self,

102

src: str = None,

103

src_base64: str = None,

104

width: float = None,

105

height: float = None,

106

fit: ImageFit = None,

107

repeat: ImageRepeat = None,

108

border_radius: BorderRadiusValue = None,

109

tooltip: str = None,

110

color: str = None,

111

color_blend_mode: BlendMode = None,

112

**kwargs

113

)

114

```

115

116

**Parameters:**

117

- `src` (str, optional): Image URL or asset path

118

- `src_base64` (str, optional): Base64-encoded image data

119

- `width` (float, optional): Image width

120

- `height` (float, optional): Image height

121

- `fit` (ImageFit, optional): How image should fit in its container

122

- `repeat` (ImageRepeat, optional): Image repeat behavior

123

- `border_radius` (BorderRadiusValue, optional): Border radius

124

- `tooltip` (str, optional): Tooltip text

125

- `color` (str, optional): Color overlay

126

- `color_blend_mode` (BlendMode, optional): Color blending mode

127

128

**Example:**

129

```python

130

ft.Image(

131

src="https://picsum.photos/200/200?1",

132

width=200,

133

height=200,

134

fit=ft.ImageFit.COVER,

135

border_radius=ft.border_radius.all(10)

136

)

137

```

138

139

### Divider

140

141

```python { .api }

142

class Divider(Control):

143

"""Horizontal divider line."""

144

145

def __init__(

146

self,

147

height: float = None,

148

thickness: float = None,

149

color: str = None,

150

**kwargs

151

)

152

```

153

154

**Parameters:**

155

- `height` (float, optional): Divider height including padding

156

- `thickness` (float, optional): Line thickness

157

- `color` (str, optional): Divider color

158

159

### VerticalDivider

160

161

```python { .api }

162

class VerticalDivider(Control):

163

"""Vertical divider line."""

164

165

def __init__(

166

self,

167

width: float = None,

168

thickness: float = None,

169

color: str = None,

170

**kwargs

171

)

172

```

173

174

**Parameters:**

175

- `width` (float, optional): Divider width including padding

176

- `thickness` (float, optional): Line thickness

177

- `color` (str, optional): Divider color

178

179

## Input Controls

180

181

### TextField

182

183

```python { .api }

184

class TextField(Control):

185

"""Text input field."""

186

187

def __init__(

188

self,

189

value: str = None,

190

label: str = None,

191

hint_text: str = None,

192

helper_text: str = None,

193

error_text: str = None,

194

prefix_text: str = None,

195

prefix_icon: str = None,

196

suffix_text: str = None,

197

suffix_icon: str = None,

198

password: bool = None,

199

can_reveal_password: bool = None,

200

multiline: bool = None,

201

min_lines: int = None,

202

max_lines: int = None,

203

max_length: int = None,

204

keyboard_type: KeyboardType = None,

205

text_capitalization: TextCapitalization = None,

206

input_filter: InputFilter = None,

207

filled: bool = None,

208

border: InputBorder = None,

209

border_radius: BorderRadiusValue = None,

210

border_color: str = None,

211

border_width: float = None,

212

focused_border_color: str = None,

213

focused_border_width: float = None,

214

color: str = None,

215

bgcolor: str = None,

216

text_size: float = None,

217

text_style: TextStyle = None,

218

label_style: TextStyle = None,

219

hint_style: TextStyle = None,

220

helper_style: TextStyle = None,

221

error_style: TextStyle = None,

222

prefix_style: TextStyle = None,

223

suffix_style: TextStyle = None,

224

cursor_color: str = None,

225

selection_color: str = None,

226

autofocus: bool = None,

227

shift_enter: bool = None,

228

read_only: bool = None,

229

show_cursor: bool = None,

230

content_padding: PaddingValue = None,

231

dense: bool = None,

232

collapsed: bool = None,

233

on_change: callable = None,

234

on_submit: callable = None,

235

on_focus: callable = None,

236

on_blur: callable = None,

237

**kwargs

238

)

239

```

240

241

**Key Parameters:**

242

- `value` (str, optional): Initial text value

243

- `label` (str, optional): Label text displayed above field

244

- `hint_text` (str, optional): Placeholder text

245

- `helper_text` (str, optional): Helper text below field

246

- `error_text` (str, optional): Error message

247

- `password` (bool, optional): Whether to obscure text

248

- `multiline` (bool, optional): Allow multiple lines

249

- `keyboard_type` (KeyboardType, optional): Virtual keyboard type

250

- `on_change` (callable, optional): Callback for text changes

251

- `on_submit` (callable, optional): Callback for form submission

252

253

**Example:**

254

```python

255

def handle_change(e):

256

print(f"Text changed to: {e.control.value}")

257

258

ft.TextField(

259

label="Username",

260

hint_text="Enter your username",

261

prefix_icon=ft.icons.PERSON,

262

on_change=handle_change

263

)

264

```

265

266

### Checkbox

267

268

```python { .api }

269

class Checkbox(Control):

270

"""Checkbox input control."""

271

272

def __init__(

273

self,

274

value: bool = None,

275

tristate: bool = None,

276

label: str = None,

277

check_color: str = None,

278

fill_color: str = None,

279

overlay_color: str = None,

280

splash_radius: float = None,

281

active_color: str = None,

282

inactive_color: str = None,

283

focus_color: str = None,

284

hover_color: str = None,

285

autofocus: bool = None,

286

on_change: callable = None,

287

on_focus: callable = None,

288

on_blur: callable = None,

289

**kwargs

290

)

291

```

292

293

**Parameters:**

294

- `value` (bool, optional): Checkbox state (True/False/None for tristate)

295

- `tristate` (bool, optional): Allow three states (checked/unchecked/null)

296

- `label` (str, optional): Label text

297

- `check_color` (str, optional): Checkmark color

298

- `fill_color` (str, optional): Fill color when checked

299

- `on_change` (callable, optional): Callback for state changes

300

301

**Example:**

302

```python

303

ft.Checkbox(

304

label="I agree to the terms",

305

value=False,

306

on_change=lambda e: print(f"Checkbox changed to {e.control.value}")

307

)

308

```

309

310

### Radio

311

312

```python { .api }

313

class Radio(Control):

314

"""Radio button control."""

315

316

def __init__(

317

self,

318

value: str = None,

319

group_value: str = None,

320

label: str = None,

321

active_color: str = None,

322

inactive_color: str = None,

323

fill_color: str = None,

324

overlay_color: str = None,

325

splash_radius: float = None,

326

focus_color: str = None,

327

hover_color: str = None,

328

autofocus: bool = None,

329

toggle_on_label_click: bool = None,

330

on_change: callable = None,

331

on_focus: callable = None,

332

on_blur: callable = None,

333

**kwargs

334

)

335

```

336

337

**Parameters:**

338

- `value` (str, optional): Radio button value

339

- `group_value` (str, optional): Currently selected value in group

340

- `label` (str, optional): Label text

341

- `active_color` (str, optional): Color when selected

342

- `on_change` (callable, optional): Callback for selection changes

343

344

### RadioGroup

345

346

```python { .api }

347

class RadioGroup(Control):

348

"""Radio button group container."""

349

350

def __init__(

351

self,

352

value: str = None,

353

content: Control = None,

354

on_change: callable = None,

355

**kwargs

356

)

357

```

358

359

**Example:**

360

```python

361

ft.RadioGroup(

362

content=ft.Column([

363

ft.Radio(value="red", label="Red"),

364

ft.Radio(value="green", label="Green"),

365

ft.Radio(value="blue", label="Blue"),

366

]),

367

on_change=lambda e: print(f"Selected: {e.control.value}")

368

)

369

```

370

371

### Switch

372

373

```python { .api }

374

class Switch(Control):

375

"""Toggle switch control."""

376

377

def __init__(

378

self,

379

value: bool = None,

380

label: str = None,

381

active_color: str = None,

382

active_track_color: str = None,

383

inactive_thumb_color: str = None,

384

inactive_track_color: str = None,

385

focus_color: str = None,

386

hover_color: str = None,

387

overlay_color: str = None,

388

splash_radius: float = None,

389

thumb_color: str = None,

390

track_color: str = None,

391

autofocus: bool = None,

392

on_change: callable = None,

393

on_focus: callable = None,

394

on_blur: callable = None,

395

**kwargs

396

)

397

```

398

399

**Parameters:**

400

- `value` (bool, optional): Switch state

401

- `label` (str, optional): Label text

402

- `active_color` (str, optional): Color when enabled

403

- `on_change` (callable, optional): Callback for state changes

404

405

### Slider

406

407

```python { .api }

408

class Slider(Control):

409

"""Value slider control."""

410

411

def __init__(

412

self,

413

value: float = None,

414

min: float = None,

415

max: float = None,

416

divisions: int = None,

417

label: str = None,

418

active_color: str = None,

419

inactive_color: str = None,

420

thumb_color: str = None,

421

overlay_color: str = None,

422

mouse_cursor: MouseCursor = None,

423

autofocus: bool = None,

424

on_change: callable = None,

425

on_change_start: callable = None,

426

on_change_end: callable = None,

427

**kwargs

428

)

429

```

430

431

**Parameters:**

432

- `value` (float, optional): Current slider value

433

- `min` (float, optional): Minimum value

434

- `max` (float, optional): Maximum value

435

- `divisions` (int, optional): Number of discrete divisions

436

- `label` (str, optional): Value label text

437

- `on_change` (callable, optional): Callback for value changes

438

439

**Example:**

440

```python

441

ft.Slider(

442

min=0,

443

max=100,

444

value=50,

445

divisions=10,

446

label="Volume: {value}",

447

on_change=lambda e: print(f"Slider value: {e.control.value}")

448

)

449

```

450

451

### Dropdown

452

453

```python { .api }

454

class Dropdown(Control):

455

"""Dropdown selection control."""

456

457

def __init__(

458

self,

459

value: str = None,

460

options: List[DropdownOption] = None,

461

hint_text: str = None,

462

helper_text: str = None,

463

error_text: str = None,

464

label: str = None,

465

icon: str = None,

466

border: InputBorder = None,

467

border_radius: BorderRadiusValue = None,

468

border_color: str = None,

469

border_width: float = None,

470

focused_border_color: str = None,

471

focused_border_width: float = None,

472

color: str = None,

473

bgcolor: str = None,

474

filled: bool = None,

475

content_padding: PaddingValue = None,

476

dense: bool = None,

477

item_height: float = None,

478

max_menu_height: float = None,

479

enable_feedback: bool = None,

480

alignment: Alignment = None,

481

autofocus: bool = None,

482

on_change: callable = None,

483

on_focus: callable = None,

484

on_blur: callable = None,

485

**kwargs

486

)

487

```

488

489

**Parameters:**

490

- `value` (str, optional): Currently selected value

491

- `options` (List[DropdownOption], optional): List of dropdown options

492

- `hint_text` (str, optional): Placeholder text

493

- `label` (str, optional): Label text

494

- `on_change` (callable, optional): Callback for selection changes

495

496

**Example:**

497

```python

498

ft.Dropdown(

499

label="Choose a color",

500

options=[

501

ft.dropdown.Option("red", "Red"),

502

ft.dropdown.Option("green", "Green"),

503

ft.dropdown.Option("blue", "Blue"),

504

],

505

on_change=lambda e: print(f"Selected: {e.control.value}")

506

)

507

```

508

509

## Button Controls

510

511

### Button

512

513

```python { .api }

514

class Button(Control):

515

"""Basic button control."""

516

517

def __init__(

518

self,

519

text: str = None,

520

icon: str = None,

521

icon_color: str = None,

522

tooltip: str = None,

523

style: ButtonStyle = None,

524

content: Control = None,

525

autofocus: bool = None,

526

on_click: callable = None,

527

on_focus: callable = None,

528

on_blur: callable = None,

529

on_hover: callable = None,

530

**kwargs

531

)

532

```

533

534

**Parameters:**

535

- `text` (str, optional): Button text

536

- `icon` (str, optional): Icon name

537

- `tooltip` (str, optional): Tooltip text

538

- `style` (ButtonStyle, optional): Custom button styling

539

- `content` (Control, optional): Custom button content

540

- `on_click` (callable, optional): Click event handler

541

542

### ElevatedButton

543

544

```python { .api }

545

class ElevatedButton(Control):

546

"""Material elevated button."""

547

548

def __init__(

549

self,

550

text: str = None,

551

icon: str = None,

552

icon_color: str = None,

553

tooltip: str = None,

554

style: ButtonStyle = None,

555

content: Control = None,

556

bgcolor: str = None,

557

color: str = None,

558

elevation: float = None,

559

autofocus: bool = None,

560

on_click: callable = None,

561

on_focus: callable = None,

562

on_blur: callable = None,

563

on_hover: callable = None,

564

**kwargs

565

)

566

```

567

568

### IconButton

569

570

```python { .api }

571

class IconButton(Control):

572

"""Icon-only button control."""

573

574

def __init__(

575

self,

576

icon: str = None,

577

icon_color: str = None,

578

icon_size: float = None,

579

tooltip: str = None,

580

style: ButtonStyle = None,

581

content: Control = None,

582

selected: bool = None,

583

selected_icon: str = None,

584

selected_icon_color: str = None,

585

splash_color: str = None,

586

splash_radius: float = None,

587

hover_color: str = None,

588

focus_color: str = None,

589

highlight_color: str = None,

590

enable_feedback: bool = None,

591

mouse_cursor: MouseCursor = None,

592

autofocus: bool = None,

593

on_click: callable = None,

594

on_focus: callable = None,

595

on_blur: callable = None,

596

on_hover: callable = None,

597

**kwargs

598

)

599

```

600

601

**Example:**

602

```python

603

ft.IconButton(

604

icon=ft.icons.DELETE,

605

icon_color=ft.colors.RED,

606

tooltip="Delete item",

607

on_click=lambda e: print("Delete clicked")

608

)

609

```

610

611

### FloatingActionButton

612

613

```python { .api }

614

class FloatingActionButton(Control):

615

"""Floating action button."""

616

617

def __init__(

618

self,

619

text: str = None,

620

icon: str = None,

621

tooltip: str = None,

622

bgcolor: str = None,

623

foreground_color: str = None,

624

hover_color: str = None,

625

focus_color: str = None,

626

splash_color: str = None,

627

elevation: float = None,

628

focus_elevation: float = None,

629

hover_elevation: float = None,

630

highlight_elevation: float = None,

631

disabled_elevation: float = None,

632

content: Control = None,

633

shape: OutlinedBorder = None,

634

mini: bool = None,

635

mouse_cursor: MouseCursor = None,

636

autofocus: bool = None,

637

on_click: callable = None,

638

**kwargs

639

)

640

```

641

642

## Selection and Picker Controls

643

644

### DatePicker

645

646

```python { .api }

647

class DatePicker(Control):

648

"""Date selection picker."""

649

650

def __init__(

651

self,

652

first_date: datetime.date = None,

653

last_date: datetime.date = None,

654

current_date: datetime.date = None,

655

value: datetime.date = None,

656

help_text: str = None,

657

cancel_text: str = None,

658

confirm_text: str = None,

659

error_format_text: str = None,

660

error_invalid_text: str = None,

661

field_hint_text: str = None,

662

field_label_text: str = None,

663

switch_to_calendar_icon: str = None,

664

switch_to_input_icon: str = None,

665

date_picker_entry_mode: DatePickerEntryMode = None,

666

on_change: callable = None,

667

on_dismiss: callable = None,

668

**kwargs

669

)

670

```

671

672

### TimePicker

673

674

```python { .api }

675

class TimePicker(Control):

676

"""Time selection picker."""

677

678

def __init__(

679

self,

680

value: datetime.time = None,

681

help_text: str = None,

682

cancel_text: str = None,

683

confirm_text: str = None,

684

error_invalid_text: str = None,

685

hour_label_text: str = None,

686

minute_label_text: str = None,

687

time_picker_entry_mode: TimePickerEntryMode = None,

688

on_change: callable = None,

689

on_dismiss: callable = None,

690

**kwargs

691

)

692

```

693

694

### FilePicker

695

696

```python { .api }

697

class FilePicker(Control):

698

"""File selection picker."""

699

700

def __init__(

701

self,

702

on_result: callable = None,

703

**kwargs

704

)

705

706

def pick_files(

707

self,

708

dialog_title: str = None,

709

initial_directory: str = None,

710

file_type: FilePickerFileType = FilePickerFileType.ANY,

711

allowed_extensions: List[str] = None,

712

allow_multiple: bool = False

713

) -> None:

714

"""Open file picker dialog."""

715

716

def get_directory_path(

717

self,

718

dialog_title: str = None,

719

initial_directory: str = None

720

) -> None:

721

"""Open directory picker dialog."""

722

723

def save_file(

724

self,

725

dialog_title: str = None,

726

file_name: str = None,

727

initial_directory: str = None,

728

file_type: FilePickerFileType = FilePickerFileType.ANY,

729

allowed_extensions: List[str] = None

730

) -> None:

731

"""Open save file dialog."""

732

```

733

734

## Dialog Controls

735

736

### AlertDialog

737

738

```python { .api }

739

class AlertDialog(Control):

740

"""Alert dialog modal."""

741

742

def __init__(

743

self,

744

title: Control = None,

745

title_padding: PaddingValue = None,

746

content: Control = None,

747

content_padding: PaddingValue = None,

748

actions: List[Control] = None,

749

actions_padding: PaddingValue = None,

750

actions_alignment: MainAxisAlignment = None,

751

icon: Control = None,

752

semantics_label: str = None,

753

bgcolor: str = None,

754

shadow_color: str = None,

755

surface_tint_color: str = None,

756

elevation: float = None,

757

shape: OutlinedBorder = None,

758

clip_behavior: ClipBehavior = None,

759

inset_padding: PaddingValue = None,

760

scrollable: bool = None,

761

open: bool = None,

762

on_dismiss: callable = None,

763

**kwargs

764

)

765

```

766

767

**Example:**

768

```python

769

def show_dialog(e):

770

page.dialog = ft.AlertDialog(

771

title=ft.Text("Confirm Action"),

772

content=ft.Text("Are you sure you want to delete this item?"),

773

actions=[

774

ft.TextButton("Cancel", on_click=close_dialog),

775

ft.TextButton("Delete", on_click=confirm_delete)

776

]

777

)

778

page.dialog.open = True

779

page.update()

780

```

781

782

### BottomSheet

783

784

```python { .api }

785

class BottomSheet(Control):

786

"""Bottom sheet modal."""

787

788

def __init__(

789

self,

790

content: Control = None,

791

bgcolor: str = None,

792

elevation: float = None,

793

shape: OutlinedBorder = None,

794

clip_behavior: ClipBehavior = None,

795

constraints: BoxConstraints = None,

796

enable_drag: bool = None,

797

show_drag_handle: bool = None,

798

use_safe_area: bool = None,

799

is_scroll_controlled: bool = None,

800

maintain_bottom_view_insets_padding: bool = None,

801

open: bool = None,

802

on_dismiss: callable = None,

803

**kwargs

804

)

805

```

806

807

### SnackBar

808

809

```python { .api }

810

class SnackBar(Control):

811

"""Snack bar notification."""

812

813

def __init__(

814

self,

815

content: Control = None,

816

action: str = None,

817

action_color: str = None,

818

action_overflow_threshold: float = None,

819

show_close_icon: bool = None,

820

close_icon_color: str = None,

821

duration: int = None,

822

bgcolor: str = None,

823

elevation: float = None,

824

margin: MarginValue = None,

825

padding: PaddingValue = None,

826

width: float = None,

827

shape: OutlinedBorder = None,

828

hit_test_behavior: HitTestBehavior = None,

829

behavior: SnackBarBehavior = None,

830

dismiss_direction: DismissDirection = None,

831

open: bool = None,

832

on_action: callable = None,

833

on_visible: callable = None,

834

**kwargs

835

)

836

```

837

838

## Display and Data Controls

839

840

### Card

841

842

```python { .api }

843

class Card(Control):

844

"""Material design card."""

845

846

def __init__(

847

self,

848

content: Control = None,

849

color: str = None,

850

shadow_color: str = None,

851

surface_tint_color: str = None,

852

elevation: float = None,

853

shape: OutlinedBorder = None,

854

clip_behavior: ClipBehavior = None,

855

margin: MarginValue = None,

856

variant: CardVariant = None,

857

**kwargs

858

)

859

```

860

861

### ListTile

862

863

```python { .api }

864

class ListTile(Control):

865

"""List item tile."""

866

867

def __init__(

868

self,

869

leading: Control = None,

870

title: Control = None,

871

subtitle: Control = None,

872

trailing: Control = None,

873

is_three_line: bool = None,

874

dense: bool = None,

875

visual_density: VisualDensity = None,

876

shape: OutlinedBorder = None,

877

style: ListTileStyle = None,

878

selected_color: str = None,

879

icon_color: str = None,

880

text_color: str = None,

881

content_padding: PaddingValue = None,

882

selected: bool = None,

883

focus_color: str = None,

884

hover_color: str = None,

885

splash_color: str = None,

886

selected_tile_color: str = None,

887

tile_color: str = None,

888

enable_feedback: bool = None,

889

horizontal_title_gap: float = None,

890

min_vertical_padding: float = None,

891

min_leading_width: float = None,

892

mouse_cursor: MouseCursor = None,

893

autofocus: bool = None,

894

toggle_on_click: bool = None,

895

url: str = None,

896

url_target: str = None,

897

on_click: callable = None,

898

on_long_press: callable = None,

899

on_focus: callable = None,

900

on_blur: callable = None,

901

on_hover: callable = None,

902

**kwargs

903

)

904

```

905

906

### DataTable

907

908

```python { .api }

909

class DataTable(Control):

910

"""Data table display."""

911

912

def __init__(

913

self,

914

columns: List[DataColumn] = None,

915

rows: List[DataRow] = None,

916

sort_column_index: int = None,

917

sort_ascending: bool = True,

918

heading_row_color: str = None,

919

heading_row_height: float = None,

920

data_row_color: str = None,

921

data_row_height: float = None,

922

border: Border = None,

923

border_radius: BorderRadiusValue = None,

924

vertical_lines: BorderSide = None,

925

horizontal_lines: BorderSide = None,

926

divider_thickness: float = None,

927

column_spacing: float = None,

928

checkbox_horizontal_margin: float = None,

929

clip_behavior: ClipBehavior = None,

930

show_bottom_border: bool = None,

931

**kwargs

932

)

933

```

934

935

## Cupertino (iOS-Style) Controls

936

937

Flet provides iOS-style variants of many controls for native iOS appearance:

938

939

- **CupertinoTextField** - iOS-style text input

940

- **CupertinoButton** - iOS-style button

941

- **CupertinoCheckbox** - iOS-style checkbox

942

- **CupertinoRadio** - iOS-style radio button

943

- **CupertinoSwitch** - iOS-style toggle switch

944

- **CupertinoSlider** - iOS-style slider

945

- **CupertinoAlertDialog** - iOS-style alert dialog

946

- **CupertinoBottomSheet** - iOS-style bottom sheet

947

- **CupertinoListTile** - iOS-style list tile

948

- **CupertinoNavigationBar** - iOS-style navigation bar

949

- **CupertinoSegmentedButton** - iOS-style segmented control

950

951

These controls automatically adapt to the platform or can be used explicitly for consistent iOS appearance across platforms.

952

953

## Best Practices

954

955

### Form Handling

956

```python

957

def create_form():

958

username = ft.TextField(label="Username")

959

password = ft.TextField(label="Password", password=True)

960

961

def submit(e):

962

print(f"Login: {username.value} / {password.value}")

963

964

return ft.Column([

965

username,

966

password,

967

ft.ElevatedButton("Login", on_click=submit)

968

])

969

```

970

971

### Validation

972

```python

973

def validate_email(e):

974

if "@" not in e.control.value:

975

e.control.error_text = "Invalid email format"

976

else:

977

e.control.error_text = None

978

page.update()

979

980

ft.TextField(

981

label="Email",

982

on_change=validate_email

983

)

984

```

985

986

### Responsive Controls

987

```python

988

ft.Container(

989

content=ft.TextField(label="Search"),

990

width=lambda: min(400, page.window_width * 0.8)

991

)

992

```

993

994

This covers the essential UI controls in Flet. Each control can be extensively customized through theming, styling, and event handling to create professional, native-looking applications across all platforms.