BackButton
Automatic navigation button for returning to previous steps in multi-step forms. BackButton is automatically added to forms starting from step 2 onwards in multi-step workflows. It enables backward navigation while preserving all user input, allowing users to review and modify their previous responses without losing data. The button is automatically labeled with internationalized "Back" text that adapts to the user's language settings.
Automatic Behavior
- Auto-added: BackButton appears automatically from step 2 onwards in multi-step forms (you don't need to import or create it)
- Smart positioning: Only shows when there are previous steps to navigate to
- Internationalized: Button text automatically translates based on user locale
- Data preservation: All user input is maintained when navigating backwards
- Seamless integration: Works automatically with the form system's navigation logic
Key Features
- Non-destructive navigation: Users can go back without losing their progress
- Form state management: Previous inputs are automatically restored when returning
- User-friendly: Provides confidence for users to explore and correct their inputs
When BackButton Appears BackButton is ideal for:
- Multi-step wizards: Allow users to review and modify previous steps
- Data collection forms: Enable correction of earlier responses
- Progressive workflows: Provide flexibility in non-linear completion
- Review processes: Allow users to double-check their inputs before submission Unlike custom Button widgets, BackButton doesn't require any implementation - it's automatically managed by the form system.
Examples
Automatic Back Navigation
BackButton automatically appears on step 2+ of multi-step forms, allowing users to navigate backwards while preserving their input
Example Code
from abstra.forms import DropdownInput, NumberInput, TextInput, run
def personal_info(state):
    return [
        TextInput("Enter your full name:", key="name"),
        NumberInput("Enter your age:", key="age"),
    ]
def preferences(state):
    return [
        DropdownInput(
            "Select your favorite color:",
            ["Red", "Blue", "Green", "Yellow"],
            key="color",
        ),
        TextInput("What's your hobby?", key="hobby"),
    ]
def confirmation(state):
    name = state.get("name", "Unknown")
    age = state.get("age", "Unknown")
    color = state.get("color", "Unknown")
    hobby = state.get("hobby", "Unknown")
    return [
        TextInput(
            f"Confirm your details:\nName: {name}\nAge: {age}\nFavorite Color: {color}\nHobby: {hobby}\n\nUse the Back button to make changes, or Next to submit:",
            key="confirmation",
        )
    ]
# Run multi-step form - BackButton appears automatically from step 2 onwards
result = run([personal_info, preferences, confirmation])
# Print the result
print(result)