We’ve made changes to improve your developer experience
Anvil is always evolving to give its users full power to make any web app they wish. In this article, we’ll go over three recent features that we made specifically to give more control and options when building web apps with Anvil.
Here’s what our latest efforts empower you to do, with nothing but Python:
- Use industry-standard design language, with the Material 3 theme.
- Use smart and secure databases, with Model Classes.
- Build easily navigable multi-page apps, with Anvil’s routing dependency.
If you want to see all these features in action, take a look at this example app. The source code is available through the clone link below.
Apply industry-standard design language
How your app looks is, understandably, a huge priority when it comes to building an Anvil app. So, we’ve given you more tools to get your app to look exactly how you want it to.
First off, our new Material 3 Theme is here with plenty of shiny and sleek components for you to use.
The updated homepage of the HR Workflow App. Its sleek new look uses the new Material 3 Theme.
The Anvil Material 3 Theme is available for both new apps and existing apps. It is exhaustively documented and updated regularly.
Secondly, we’ve changed our approach to themes and enhanced the ability for you to create your own themes and components. Apps used as dependencies can now share their custom components. You can make an entire app filled with components styled exactly how you see fit, and then use this app as a dependency. This lets you build a library of components, themes and layouts that you can then use in any other app. In fact, that’s exactly how we built the Material 3 Theme!
Ensure secure and powerful database interactions
Dealing with data can be difficult – you need your data to be flexible, modifiable and accessible, yet secure. This is where Model Classes come in. Model Classes let you handle all validation, observation and transformation in one single Python script, letting you enjoy all the benefits of a secure database without compromising on flexibility.
Here are a few things Model Classes enable you to do:
- Have your user rows automatically calculate the age of the user they represent, using their registered date of birth.
- Ensure the execution of specific code whenever a new row is created or updated.
- Check for permission when a user attempts to modify a row.
For example, let’s say that we have an app where users can create accounts, and we want to notify the app owner whenever a new user is created.
from anvil.tables import app_tables
import anvil.email
class User(app_tables.users.row):
# We inherit from the Row class from our users table.
# Through Model Classes, this allows us to add logic to our row objects.
def _do_create():
# This method is run every time a new row object is created.
anvil.email.send(
to="owner@email.com",
subject="New User Registered",
text = """Hello Owner!
A new user has registered to your app.
"""
)With just this simple script, we have added logic to our data table, and now, you can too!
All this and much more is dutifully explained in Model Classes’ documentation.
Provide clear navigation
We’ve built a new way to use routing for page navigation within Anvil. Our new routing dependency makes the set-up process very easy, letting you set up and configure URL routes via a script, as you would any other element of your app.
Routing empowers you to:
- Let your users use browser bookmarks
- Redirect your users
- Enable navigation to specific app states from an external link
Navigation through the HR Workflow App, handled through the Anvil routing dependency.
Using routing for navigation offers a very native experience for your users, and the routing dependency lets you implement it the same way you would any other component. Our routing documentation is a great starting-off point, and the dependency’s standalone documentation has all the technical details you could possibly ask for.
Dive in!
We hope that these additional tools empower our users to build exactly what they have in mind, with all the features they desire. All you need to get started is sign up, and get coding. It’s that easy.
If you’re looking for an example, this example app showcases all the features described here, with explanatory comments throughout the code. You can take a look at the source code by cloning the app using the clone link below.
We also have a bunch of tutorials to help if you’re ever lost, and the Anvil community forum is filled to the brim with brilliant and helpful people, so you’re never alone.
Data Dashboard
Build Database-Backed Apps
Build a Simple Feedback Form
Build a data-entry app, and learn the techniques fundamental to building any Anvil app. In this tutorial, you will:
- Build your User Interface
- Write client-side Python
- Write server-side Python
- Store data in a database
- Deploy your app
By