Тема и оформление
Nano’s Razor Pages UI uses Bootstrap 5 for its base styles and a custom SCSS theme for colors, spacing, typography, and component styling. The theme files are located in wwwroot/assets/scss, with nanite-theme.scss serving as the main stylesheet.
You can customize the theme by editing the SCSS files and running the project’s stylesheet watcher to compile your changes into CSS.
Setting Up SCSS Compilation
To edit the theme, install the frontend dependencies and start the SCSS watcher.
- Open a terminal and navigate to the
wwwrootfolder. - Install the dependencies:
npm install - Start the stylesheet watcher:
npm run watchscss
Once the watcher is running, changes to watched .scss files should trigger CSS recompilation. Reload the browser to see the updated styles.
The watcher and its output are defined by the project’s npm scripts and build configuration. If compilation fails, check that the required Sass compiler and dependencies are installed.
Global Theme Variables
Этот _variables.scss file contains global theme variables that customize Bootstrap defaults, including colors, sizes, and spacing. Updating these variables is a convenient way to change the application’s appearance consistently without overriding individual components one by one.
The main stylesheet, nanite-theme.scss, builds on the base Bootstrap 5 styles provided by the project’s npm dependencies.
Bootstrap’s theming system determines how variables and styles are applied, so the order of imports matters. Custom variables generally need to be defined before the Bootstrap styles that use them are compiled.
For more information, see the Bootstrap 5 theming documentation.
Custom Styles
Styles that are not part of the global theme are organized under the custom directory. The main categories include:
- Components — styles for reusable UI components.
- Страницы — styles specific to individual pages.
- Structure — styles for the application’s overall layout.
- Fonts — font definitions and related styling.
- Icons — icon-related styles.
- Plugins — styles for third-party libraries and UI components.
When customizing the application, prefer updating existing variables or component styles where possible. Use page-specific styles for isolated changes and global styles for rules that should apply throughout the application.
Theme JavaScript
Nano’s theme JavaScript files are located in wwwroot/assets/js. The main files include:
Nanite-core.js— initializes UI components and configures validation-related behavior.Nanite-layout.js— manages theme color mode and sidebar state.Nanite-helpers.js— provides shared utility functions.
When adding or modifying frontend components, check whether they depend on these shared scripts or require additional JavaScript and CSS assets.
Следующие шаги
You’ve now covered the main styling features of Nano’s Razor Pages UI. Explore the Vue setup guide и React setup guide, or continue to the Руководство по Web API в ASP.NET Core to learn about the backend architecture.