CARVIEW |
Select Language
HTTP/2 200
date: Sat, 19 Jul 2025 22:11:57 GMT
content-type: text/html; charset=utf-8
vary: X-PJAX, X-PJAX-Container, Turbo-Visit, Turbo-Frame, X-Requested-With,Accept-Encoding, Accept, X-Requested-With
etag: W/"654c3b425aa6dc76e978751d43dc65ae"
cache-control: max-age=0, private, must-revalidate
strict-transport-security: max-age=31536000; includeSubdomains; preload
x-frame-options: deny
x-content-type-options: nosniff
x-xss-protection: 0
referrer-policy: no-referrer-when-downgrade
content-security-policy: default-src 'none'; base-uri 'self'; child-src github.githubassets.com github.com/assets-cdn/worker/ github.com/assets/ gist.github.com/assets-cdn/worker/; connect-src 'self' uploads.github.com www.githubstatus.com collector.github.com raw.githubusercontent.com api.github.com github-cloud.s3.amazonaws.com github-production-repository-file-5c1aeb.s3.amazonaws.com github-production-upload-manifest-file-7fdce7.s3.amazonaws.com github-production-user-asset-6210df.s3.amazonaws.com *.rel.tunnels.api.visualstudio.com wss://*.rel.tunnels.api.visualstudio.com objects-origin.githubusercontent.com copilot-proxy.githubusercontent.com proxy.individual.githubcopilot.com proxy.business.githubcopilot.com proxy.enterprise.githubcopilot.com *.actions.githubusercontent.com wss://*.actions.githubusercontent.com productionresultssa0.blob.core.windows.net/ productionresultssa1.blob.core.windows.net/ productionresultssa2.blob.core.windows.net/ productionresultssa3.blob.core.windows.net/ productionresultssa4.blob.core.windows.net/ productionresultssa5.blob.core.windows.net/ productionresultssa6.blob.core.windows.net/ productionresultssa7.blob.core.windows.net/ productionresultssa8.blob.core.windows.net/ productionresultssa9.blob.core.windows.net/ productionresultssa10.blob.core.windows.net/ productionresultssa11.blob.core.windows.net/ productionresultssa12.blob.core.windows.net/ productionresultssa13.blob.core.windows.net/ productionresultssa14.blob.core.windows.net/ productionresultssa15.blob.core.windows.net/ productionresultssa16.blob.core.windows.net/ productionresultssa17.blob.core.windows.net/ productionresultssa18.blob.core.windows.net/ productionresultssa19.blob.core.windows.net/ github-production-repository-image-32fea6.s3.amazonaws.com github-production-release-asset-2e65be.s3.amazonaws.com insights.github.com wss://alive.github.com api.githubcopilot.com api.individual.githubcopilot.com api.business.githubcopilot.com api.enterprise.githubcopilot.com; font-src github.githubassets.com; form-action 'self' github.com gist.github.com copilot-workspace.githubnext.com objects-origin.githubusercontent.com; frame-ancestors 'none'; frame-src viewscreen.githubusercontent.com notebooks.githubusercontent.com; img-src 'self' data: blob: github.githubassets.com media.githubusercontent.com camo.githubusercontent.com identicons.github.com avatars.githubusercontent.com private-avatars.githubusercontent.com github-cloud.s3.amazonaws.com objects.githubusercontent.com release-assets.githubusercontent.com secured-user-images.githubusercontent.com/ user-images.githubusercontent.com/ private-user-images.githubusercontent.com opengraph.githubassets.com copilotprodattachments.blob.core.windows.net/github-production-copilot-attachments/ github-production-user-asset-6210df.s3.amazonaws.com customer-stories-feed.github.com spotlights-feed.github.com objects-origin.githubusercontent.com *.githubusercontent.com; manifest-src 'self'; media-src github.com user-images.githubusercontent.com/ secured-user-images.githubusercontent.com/ private-user-images.githubusercontent.com github-production-user-asset-6210df.s3.amazonaws.com gist.github.com; script-src github.githubassets.com; style-src 'unsafe-inline' github.githubassets.com; upgrade-insecure-requests; worker-src github.githubassets.com github.com/assets-cdn/worker/ github.com/assets/ gist.github.com/assets-cdn/worker/
server: github.com
content-encoding: gzip
accept-ranges: bytes
set-cookie: _gh_sess=mz8ArtJs1ad2IgoZcuQr1Kvi5pvRMCG8Su1wUuTeF8mlesp1HfiLUTQY3jnlHDGSeCsasNgQW2K8ru3kIa7u1Ypid9V8%2FV38AHEIetqLOoO1eWt4t8y1u39%2BjYS%2BqSdukf6f04rIhapInaBBu2%2FIaE8z0%2BZNRQSo6aTiO0%2BycH5N0EP50B5db7nWsL6H6ExIQKtqsejvqx31hrhlSAnZnX0u0TFeLznwuAPp2%2FJYxc5cqUAvOfjVC2f1aCM%2BxgvTHZUtg5e%2FAslYQvvpD0xZMw%3D%3D--AQkROuNp5ZrosAEE--M0n0NXXKPAo9U1vlFlTVqg%3D%3D; Path=/; HttpOnly; Secure; SameSite=Lax
set-cookie: _octo=GH1.1.90955000.1752963117; Path=/; Domain=github.com; Expires=Sun, 19 Jul 2026 22:11:57 GMT; Secure; SameSite=Lax
set-cookie: logged_in=no; Path=/; Domain=github.com; Expires=Sun, 19 Jul 2026 22:11:57 GMT; HttpOnly; Secure; SameSite=Lax
x-github-request-id: C6CA:0A55:80764F:A277DE:687C182D
Component API guidelines · carbon-design-system/carbon-components-angular Wiki · GitHub
Skip to content
Navigation Menu
{{ message }}
-
Notifications
You must be signed in to change notification settings - Fork 313
Component API guidelines
Callum Smith edited this page Apr 16, 2019
·
3 revisions
Do:
// Inputs should declare a type and initialize to some sane default value
@Input() items: Array<Object> = [];
// string options should declare a union of all possible options
// and initialize to a default option
@Input() type: "single" | "multi" = "single";
// Inputs should prefer short, clear, names since their function should be
// obvious given the component they are attached to.
// If not the component should be refactored.
@Input() open = false;
@Input() title = "";
Don't:
// what's the type? what's the default?
@Input() items;
// what possible options can we pass in?
@Input() type = "single";
// descriptive is good, however this is a sign the component may need
// to be refactored, or broken down into composable sub-components.
@Input() isMenuOpen: boolean = false;
Do:
@Input() items = [
{
content: "content here",
// only for selectable item lists
selected: false,
// false or not including the property is the same behaviour
disabled: false
// other properties can be included.
// if there is a template the whole object should be passed to it.
},
{
content: "more content",
selected: true
}
];
Don't:
@Input() myComponentItems = [
"content",
"more content"
];
@Input() alsoWrong = {
item1: {}
item2: {}
};
Do:
@Input() items = [
{
content: "content here",
// only for selectable item lists
selected: false,
// false or not including the property is the same behaviour
disabled: false
// other properties can be included.
// if there is a template the whole object should be passed to it.
},
{
content: "more content",
selected: true,
// nested item lists follow the exact same conventions as
// regular item lists however, they live within some parent item.
items: [
{
content: "nested item",
selected: false
}
]
}
];
Don't:
@Input() myComponentItems = [
"content",
"more content",
[
"something else"
]
];
@Input() alsoWrong = {
item1: {
subItems: {}
}
item2: {}
};
Do:
@Component({
// the component selector should be a kebab case translation of the
// component class name prefixed with "ibm"
selector: "ibm-foo",
// templates should be inlined using ES6 template strings.
// if the template grows too large, the component should
// be refactored and/or split up. external html templates should
// NOT be used.
template: `
<p>My Component</p>`,
// styles should not be needed as styling will come from carbon-components,
// however, in the rare case that additional styling is required
// inline styles via the `styles` array may be used.
styles: [
`
.foo
color: blue;
}
]
})
// the exported class should NOT be prefixed, or suffixed with Component
export class Foo {
//...
}
Don't:
@Component({
// should be a translation of the component class
// should be prefixed with "ibm"
selector: "some-component",
// should be an inline template string
templateUrl: "./my-component.component.html"
})
// the exported class should NOT be prefixed, or suffixed with Component
export class IBMFooComponent {
//...
}
Clone this wiki locally
You can’t perform that action at this time.