function hook_css_alter
Same name in other branches
- 7.x modules/system/system.api.php \hook_css_alter()
- 9 core/lib/Drupal/Core/Render/theme.api.php \hook_css_alter()
- 8.9.x core/lib/Drupal/Core/Render/theme.api.php \hook_css_alter()
- 10 core/lib/Drupal/Core/Render/theme.api.php \hook_css_alter()
Alter CSS files before they are output on the page.
Parameters
$css: An array of all CSS items (files and inline CSS) being requested on the page.
\Drupal\Core\Asset\AttachedAssetsInterface $assets: The assets attached to the current response.
\Drupal\Core\Language\LanguageInterface $language: The language of the request that the assets will be rendered for.
See also
Drupal\Core\Asset\LibraryResolverInterface::getCssAssets()
Related topics
1 invocation of hook_css_alter()
- AssetResolver::getCssAssets in core/
lib/ Drupal/ Core/ Asset/ AssetResolver.php - Returns the CSS assets for the current response's libraries.
File
-
core/
lib/ Drupal/ Core/ Render/ theme.api.php, line 1072
Code
function hook_css_alter(&$css, \Drupal\Core\Asset\AttachedAssetsInterface $assets, \Drupal\Core\Language\LanguageInterface $language) {
// Remove defaults.css file.
$file_path = \Drupal::service('extension.list.module')->getPath('system') . '/defaults.css';
unset($css[$file_path]);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.