# @ajsf/bootstrap4
[](https://sonarcloud.io/summary/new_code?id=hamzahamidi_ajsf)
Bootstrap 4 framework for [AJSF](https://github.com/hamzahamidi/ajsf#readme), which builds Angular forms from JSON Schema.
## Getting started
Install the package and Bootstrap 4:
```shell
npm install @ajsf/bootstrap4 bootstrap@4
```
Add Bootstrap's stylesheet to the `styles` of the build target in `angular.json`:
```json
"styles": [
"node_modules/bootstrap/dist/css/bootstrap.min.css",
"src/styles.css"
]
```
Import `Bootstrap4FrameworkModule` in the standalone component that renders the form. Nothing goes in `app.config.ts`:
```typescript
import { Component } from '@angular/core';
import { Bootstrap4FrameworkModule } from '@ajsf/bootstrap4';
@Component({
selector: 'app-root',
imports: [Bootstrap4FrameworkModule],
templateUrl: './app.html',
})
export class App {
schema = {
type: 'object',
properties: {
name: { type: 'string', title: 'Name' },
plan: { type: 'string', title: 'Plan', enum: ['free', 'pro', 'team'] },
},
required: ['name'],
};
onSubmit(data: any) {
console.log(data);
}
}
```
In an `NgModule` app, add `Bootstrap4FrameworkModule` to the module's `imports` instead.
Then render the form in the component's template:
```html
```
`framework="bootstrap-4"` selects this package's templates. The other values are `material-design`, `primeng`, `bootstrap-3`, `bootstrap-5` and `no-framework`, the default.
To try the library without installing Bootstrap, bind `[loadExternalAssets]="true"` on `` instead, which loads Bootstrap 4 from a CDN. Load the assets yourself in production.
The [AJSF README](https://github.com/hamzahamidi/ajsf#readme) covers the other inputs and outputs, layouts, custom widgets and validation messages.
## Bootstrap 4 markup, corrected in 20.1.0
This package previously emitted Bootstrap 3 class names. It was created as a
copy of `@ajsf/bootstrap3` with the CDN URL changed, so classes Bootstrap 4
had dropped kept being rendered and silently did nothing. If you have written
CSS against the old output, these are the names that changed.
| Was | Is now | Why |
| --- | --- | --- |
| `has-error`, `has-success`, `has-feedback` | `is-invalid` on the field wrapper | Bootstrap 4 marks the field, not the container |
| `help-block` | `form-text text-muted` | Bootstrap 4's help text class |
| `form-control-feedback`, `glyphicon` | removed | Bootstrap 4 ships no glyphicons |
| `input-group-addon` | `input-group-prepend` or `input-group-append` wrapping `input-group-text` | Bootstrap 4's addon structure |
| `pull-right` | `float-right` | renamed in Bootstrap 4 |
| `control-label` | no class | Bootstrap 4 styles a plain label in a stacked form |
| `btn-default` | `btn-secondary` | Bootstrap 4's neutral button |
`form-group` and `sr-only` are unchanged, because Bootstrap 4 still defines
both.
Validation messages also behave differently, and this part applies to
`@ajsf/bootstrap3` and `@ajsf/bootstrap5` too. A message used to appear only
once the value had changed, so focusing a required field and leaving it empty
showed nothing. It now appears once the field has been touched or changed.
Error text and help text are also separate elements now, so you can style one
without the other.
## Checkbox and radio structure, changed in 22.1.0
Checkboxes and radios previously rendered the `` inside its `