How should I add a “widget” like element?

This is entirely up to you. Both approaches should do the same thing. I really do think that you having trouble with correct implementation of your first choice/approach.

What you are trying to do is correct using a separate template for your slideshow and then calling it with get_template_part(). The problem it seems is your styling. Style tags are valid outside the <head></head> tags, this is wht you use for inline styles, however, it is not recommended to use inline styles as they are difficult to override with child themes and plugins and inline styles cannot be removed by simply dequeueing or deregistering it.

What is not allowed outside the <head></head> tags is link tags. That is invalid HTML should you do that.

Whether or not you decide to make use of a template part o a widget, you will have to load your styles, so with both approaches you are back to square one if you don’t load your styles correctly. Here is how to load your styles correctly

  • Create a new stylesheet and call it whatever you like, something like slider-style.css

  • Add all your styling for your slider in this file.

  • Enqueue your stylesheet with wp_enqueue_style() inside a function. If you need to load your stylesheet conditionally, use wp_register_style() to register the style and then enqueue your style conditionally

  • Hook your function to wp_enqueue_scripts. This will add your styles to wp_head

Example:

Say your slider will only be used on the homepage, you can try the following

add_action( 'wp_enqueue_scripts', 'enqueue_slider_styles', PHP_INT_MAX );
function enqueue_slider_styles() 
{
    wp_register_style( 'slider-styles', get_template_directory_uri() . '/slider-style.css' );
    if ( is_home() ) {
        wp_enqueue_style( 'slider_styles' );
    }
}

This will now load your slider stylesheet only on the home page. I assumed a parent theme here, if you are using a child theme (which you should always use if you want to make changes to a theme you did not write yourself), then you should use get_stylesheet_directory_uri() in place of get_template_directory_uri()

REFERENCES: